Skip to content

nowiko/yii-sluggable-behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Scrutinizer Code Quality Maintainability

SluggableBehavior

SluggableBehavior - is a simple tool for making your app URL's more readable.

Note: Do not forget to configure 'urlManager' component of your application.

Basic usage:

  1. Download the behavior to your project via git clone or manually as archive.

  2. Configure your model class according to sample below:

public function behaviors()
{
    return array(
         'sluggableBehavior' => array(
             'class'          => 'path.to.behavior.SluggableBehavior',
             'delimiter'      => '-',    // words delimiter
             'sluggable_attr' => 'name', // name of attr what need to be "slugged"
             'slug_attr'      => 'slug', // attr for store slug
             'allow_update'   => true,   // allow update slug or not
             'length'         => 5,     // length of words to place into slug
         ),
    );
}

Now you are able to use slug attribute in your URLs.