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 [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem