Add a slug field to any DataObject
This SilverStripe module allows the developer to add a field that will be converted to a slug (kebab case) when saved
For any given class that needs slugs, the extension
Suilven\Sluggable\Extension\Sluggable needs added and also
the name of the field name to slug, under the key
slug. The slug is stored in a field called
Slug on the data object
after a write is executed.
--- Name: cricket-slugs --- Suilven\CricketSite\Model\Club: extensions: - Suilven\Sluggable\Extension\Sluggable slug: Name Suilven\CricketSite\Model\Player: extensions: - Suilven\Sluggable\Extension\Sluggable slug: DisplayName
vendor/bin/sake dev/build flush=all
Then reload the browser,
Now when the above models are saved, they will be saved with a slug associated with them.
$ composer require suilven/sluggable
Assuming the configuration above:
$club = new Suilven\CricketSite\Model\Club(); $club->Name = 'GitHub Cricket Club'; $club->write(); echo $club->Slug
The value output will be
Please see CHANGELOG for more information on what has changed recently.
$ composer test
If you discover any security related issues, please email firstname.lastname@example.org instead of using the issue tracker.
- [Gordon Anderson][link-author]
The MIT License (MIT). Please see License File for more information.