skeeks / yii2-ya-slug
Yii2 yandex slug
Installs: 4 168
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- cocur/slugify: ^3.0
- yiisoft/yii2: ^2
This package is auto-updated.
Last update: 2024-10-24 00:23:18 UTC
README
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
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
echo skeeks\yii2\yaslug\YaSlugBehavior::slugify("Тестовая строка");
Links
Demo (view urls)
SkeekS CMS (Yii2) — fast, simple, effective!
skeeks.com | cms.skeeks.com