NAME
Strehler::Element::Role::Slugged - A role to manage element's slug
DESCRIPTION
A slugged Strehler element provides an authomatic management of a slug (multilanguage or not). Slug can then be used to retrieve the element itself.
Default implementation that come with the role is the one used by Strehler::Element::Article but methods can be overridden for different behaviours.
A slugged element must include, in its database representation, a field named slug (VARCHAR), in the main table or in the table of multilanguage contents.
SYNOPSIS
my $article = Strehler::Element::Article->get_by_slug('a-slug-suitable-for-web', $language)
FUNCTIONS
- multilang_slug
-
Return 1 if the slug is multilanguage and comes from the multilanguage contents table.
- to_slug
-
Return the field, from the form, that will be used to make the slug.
- save_slug
-
Hook used by save_form method from Strehler::Element.
It takes the field with the name returned by to_slug from the POSTed form and create a slug from it using Strehler::Helpers slugify function.
Slug is guaranteed unique because, in any case, element ID is preferred to the slug string.
- get_by_slug
-
Function to retrieve elements using slug.
An element that implements this method returns true when slugged() function (Strehler::Element::Role::Configured) is called.