SluggableBehavior - is a simple tool for making your app URL's more readable.
Note: Do not forget to configure 'urlManager' component of your application.
-
Download the behavior to your project via git clone or manually as archive.
-
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.