Forum

Thread tagged as: Question

reuse id in template

I am trying to basically reuse an id in a template to add a navigation list but i think it's not the right way to do it... Beginner's question...

<ul>
    <li><a href="#<perch:content id="any_id" type="text" label="Any Label"/>"><perch:content id="any_id" type="text" label="Any Label"/></a></li>
</ul>
<h2 id="<perch:content id="any_id" type="text" label="Any Label"/>"><perch:content id="any_id" type="text" label="Any Label"/></h2>
DEVAUX Nicolas

DEVAUX Nicolas 0 points

  • 5 years ago

That's right, but you probably want to use a slug so caps/spaces/etc. don't break your ID:

<ul>
  <li><a href="#<perch:content id="any_slug" type="slug" for="any_id" />"><perch:content id="any_id" type="text" label="Any Label"/></a></li>
</ul>
<h2 id="<perch:content id="any_slug" type="slug" for="any_id" />"><perch:content id="any_id" type="text" label="Any Label"/></h2>

My solution is not good as it's not working at all. Maybe i should investigate slugs that i never used before.

In what way is it not working? Is it not outputting to the page? Are other regions working and outputting?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Thanks Rachel. I did it some other way because i am using blocks and repeaters but this tutorial helped me with the perch_item_index.

My navigation is ok now.