2017 © Pedro Peláez
 

yii2-extension yii2-slug-behavior

Yii2 slug behavior

image

skeeks/yii2-slug-behavior

Yii2 slug behavior

  • Wednesday, November 8, 2017
  • by skeeks-semenov
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,201 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 46 % Grown

The README.md

Yii2 slug behavior (Semantic URL)

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

Direct generation is engaged in a proven solution cocur/slugify., (*2)

Latest Stable Version Total Downloads, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

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

or add, (*6)

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

How to use

Attach the behavior in your model:, (*7)

public function behaviors()
{
    return [
        'slug' => [
            'class' => 'skeeks\yii2\slug\SlugBehavior',
            '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,
            'slugifyOptions' => [
                'lowercase' => true,
                'separator' => '-',
                'trim' => true
                //'regexp' => '/([^A-Za-z0-9]|-)+/',
                //'rulesets' => ['russian'],
                //@see all options https://github.com/cocur/slugify
            ]
        ]
    ];
}

Yandex translit http://translit-online.ru/yandex.html:, (*8)

public function behaviors()
{
    return [
        'slug' => [
            'class' => 'skeeks\yii2\slug\SlugBehavior',
            'slugAttribute' => 'slug',                      //The attribute to be generated
            'attribute' => 'name',                          //The attribute from which will be generated
            // optional params
            'slugifyOptions' => [
                'rulesets' => [
                    skeeks\yii2\slug\SlugRuleProvider::YANDEX, 
                    'default'
                ]
            ]
        ]
    ];
}

Demo (view urls)


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

The Versions

08/11 2017

dev-master

9999999-dev https://skeeks.com/

Yii2 slug behavior

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

yii2 yii behavior slug

04/11 2017

1.0.0

1.0.0.0 https://skeeks.com/

Yii2 slug behavior

  Sources   Download

GPL-3.0+

The Requires

 

by Semenov Alexander

yii2 yii behavior slug