Forum

Thread tagged as: Question

Navgroup Based on Page Name

Hello,

I would like to display a specific navgroup based on a page's name. Is this possible?

I would create navgroups for each page, so I could manually select which pages I would want linked to on the page.

My reason for doing this is because many directories of my website need to link to the same content, located in a different directory and it doesn't make sense to have the file duplicated in each directory.

Thank you! -Trevor

Trevor Brandt

Trevor Brandt 0 points

  • 3 years ago
Simon Clay

Simon Clay 127 points

Hi Trevor, it sounds like you're wanting to show these Navgroups as part of the main Nav?

I think it could possible. Below are the steps I think would be necessary:

1) Pass each Navgroup into a variable (probably using a template to put it into a list format) https://docs.grabaperch.com/templates/passing-variables-into-templates/

2) In your Nav template, test for each page and and output the appropriate navgroup variable... e.g.

<perch:if id="pagePath" match="/about-us" value="eq">
  <perch:pages id="about_us_nav">
</perch:if>
<perch:if id="pagePath" match="/services" value="eq">
  <perch:pages id="services_nav">
</perch:if>