No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
CHANGELOG.md
LICENSE
README.md
composer.json

README.md

Yii2 yandex slug (Semantic URL)

This solution allows you to generate good slug urls. (slug wiki).

Direct generation is engaged in a proven solution cocur/slugify.

Transliteration yandex http://translit-online.ru/yandex.html

Latest Stable Version Total Downloads GPL-3.0 License Reference Status Dependency Status

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist skeeks/yii2-ya-slug "*"

or add

"skeeks/yii2-ya-slug": "*"

How to use

behavior

Attach the behavior in your model:

public function behaviors()
{
    return [
        'slug' => [
            'class' => 'skeeks\yii2\yaslug\YaSlugBehavior',
            'slugAttribute' => 'slug',                      //The attribute to be generated
            'attribute' => 'name',                          //The attribute from which will be generated
            // optional params
            'maxLength' => 64,                              //Maximum length of attribute slug
            'minLength' => 3,                               //Min length of attribute slug
            'ensureUnique' => true,
        ]
    ];
}

helper

<?php
echo skeeks\yii2\yaslug\YaSlugBehavior::slugify("Тестовая строка");

Links

Demo (view urls)


skeeks!
SkeekS CMS (Yii2) — fast, simple, effective!
skeeks.com | cms.skeeks.com