Forum
Can perch_item_index be used as a “for” attribute on a slug?
Attempting to create a very specific slug for a client who sometimes will upload content with the same value for every field (i.e. title="untitled" date="2015") so I'm trying to get more specific with the slug and possibly add a legitimate unique ID to each item.
My first thought was to use perch_item_index to create a unique number for each item but that doesn't seem to be working in my template.
Any help appreciated! Thanks, T
TL;DR: content is setup for use on a list and detail page, attempting to create a unique link for each item.
Every item has a unique ID, so combining the ID with the slug might be an option. I would have to run an experiment on my test environment to be for sure.
perch_item_index
is the index of an item in the set as it is sent to the template engine - it's not a property of the content itself. If you resort the region, the index will change.Slugs currently require the
for
fields to be part of the same form data that is posted when the slug is created. That's not the case with the index or the ID, as new items don't have an ID yet.You could use the ID in place of a slug - that's probably the route to go.
Thanks Robert and Drew. Using _id in lieu of slug worked great.