Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/baibaratsky/yii2-slug-behavior
Yii2 slug behavior
https://github.com/baibaratsky/yii2-slug-behavior
Last synced: about 1 month ago
JSON representation
Yii2 slug behavior
- Host: GitHub
- URL: https://github.com/baibaratsky/yii2-slug-behavior
- Owner: baibaratsky
- License: other
- Created: 2014-02-14T22:04:44.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-17T09:56:50.000Z (over 9 years ago)
- Last Synced: 2024-04-22T04:46:20.270Z (7 months ago)
- Language: PHP
- Size: 146 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Yii2 slug behavior
==================>**I’d made this behavior before Yii2 became beta. At the moment, there is no need to use this behavior, because Yii2 has its own implementation — `SluggableBehavior`.**
This Yii2 model behavior automates the slug generation process. To attach the behavior put the following code in your model:
```php
public function behaviors()
{
return [
'slug' => [
'class' => Slug::className(),// These parameters are optional, default values presented here:
'sourceAttributeName' => 'name', // If you want to make a slug from another attribute, set it here
'slugAttributeName' => 'slug', // Name of the attribute containing a slug
'replacement' => '-', // The replacement to use for spaces in the slug
'lowercase' => true, // Whether to return the string in lowercase or not
'unique' => true, // Check if the slug value is unique, add number if not
],
];
}
```