We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Problem

Creating Slug from _id

in a multi item region I want to create a slug using the item _id but using the fieldtype hidden causes the slug not to be created:

<perch:content id="_id" type="hidden" suppress="true" />
<perch:content id="slug" type="slug" for="_id" suppress="true" />

Using the field type text eg. <perch:content id="_id" type="hidden" suppress="true" /> works correctly but shows a field with the id on the edit page, which I don't want.

How can I create a slug from the _id but not show it on the edit page?

Simon Clay

Simon Clay 127 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Why would you need to create a slug from the _id? Just use _id - the slug output would be the same.

Simon Clay

Simon Clay 127 points

That's the method I tried first.

The link in the list page outputs the link correctly, but on clicking the link, the detail page is not displayed, the url is correct eg. my website.com/jobs/49 but it only shows the site header and footer, no detail page.

<a href="/jobs/<perch:content id="_id" type="hidden" suppress="true" />" >

In region options I also changed 'URL for single items' to /jobs/{slug}

Did I forget something, perhaps in the detail template?

Simon Clay

Simon Clay 127 points

Oh, I think I forgot to swap out slug for _id in perch_content_custom`