Forum
How to make a unique slug for multiple item region item?
I have a multiple item region with a title field feeding a slug (interesting picture there). Turns out the client wants to use duplicate titles, so we need a way to unique-ify the slug.
I see in the docs that the slug
type can take a space-separated list of field ids in the for
attribute. Great.
But it doesn't seem to work with the built-in _id
.
Example:
<perch:content for="title _id" id="slug" type="slug" />
If the _id
is included as a field in the template then it works as expected, but if that field is hidden the _id
is no longer included in the slug
.
The big question is how can I create a unique slug for a multiple item region item?
The next question is can a slug type tag use an _id
? (also tried a date
, but that didn't seem to work either)
Perch 2.8.8
You can use any of the fields that are in the form.
_id
isn't in the form, so that won't work.For dates, you need to specify the component, e.g.
date_year
Great, thanks Drew. Here's the resulting template tag for anyone finding this through search: