skeeks / yii2-ya-slug
Yii2 yandex slug
1.0.3
2020-09-23 14:53 UTC
Requires
- cocur/slugify: ^3.0
- yiisoft/yii2: ^2
This package is auto-updated.
Last update: 2024-08-23 23:59:39 UTC
README
此解决方案允许您生成良好的缩略URL。 (缩略URL 维基)
直接生成使用的是经过验证的解决方案 cocur/slugify。
使用雅虎转写 http://translit-online.ru/yandex.html
安装
通过 composer 安装此扩展是首选方式。
运行以下命令:
php composer.phar require --prefer-dist skeeks/yii2-ya-slug "*"
或者添加以下内容:
"skeeks/yii2-ya-slug": "*"
如何使用
行为
在您的模型中附加行为
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, ] ]; }
辅助工具
echo skeeks\yii2\yaslug\YaSlugBehavior::slugify("Тестовая строка");
链接
演示(查看URLs)
SkeekS CMS (Yii2) — 快速、简单、高效!
skeeks.com | cms.skeeks.com