Forum

Thread tagged as: Question

Can the user set the ID name for on page anchor tags?

User wants to be able to click a sub nav and go to a specific section on a page using anchor tags. To do this, they need to set the URL in the link to go to, e.g. #jobs, and the ID of that section needs to match. Can the user set the ID in Perch admin?

Danny Turley

Danny Turley 0 points

  • 4 years ago
Simon Clay

Simon Clay 127 points

Hi Danny, yes it is possible.

To start with the template can automatically add the id, for instance, like this:

<section id="<perch:content id="text" type="text" label="Heading" title="true" urlify="true" />">
    <h2><perch:content id="text" type="text" label="Heading" title="true" /></h2>
    <perch:content id="text" type="textarea" label="Text" html="true" editor="redactor" />
</section>

With this template Perch will set the ID to be a 'urlified' version of the heading. e.g. Heading: Where to Find Us would be used as an ID of where-to-find-us.

Ah, I was missing the Urlify. Thanks, Simon.