Forum
Navigation Links
Hi,
We're working on a couple of sites on the latest release and we've had problems getting the navigation to link correctly. I'm working on a site at the moment that shows the full nav as requested by the homepage link is broken - another site its an internal page. The outputted code for the link is missing its 'href':
<li class="full-nav__item">
<a href="" class="nav-link " itemprop="url">
<span itemprop="name">
Home
</span>
</a>
</li>
<li class="full-nav__item">
<a href="/contact-us.php" class="nav-link --active " itemprop="url">
<span itemprop="name">
Contact us
</span>
</a>
</li>
Code we're using for the nav is just:
<a href="<perch:pages id="pagePath" />" class="nav-link<perch:if exists="current_page"> --active</perch:if> <perch:if exists="ancestor_page"> --active</perch:if>" itemprop="url">
<span itemprop="name">
<perch:pages id="pageNavText" />
</span>
</a>
So I'm a bit stuck. Looking at the database all the fields look correct and deleting the page in Perch and adding again hasn't fixed it...any help would be appreciated.
Kind Regards, Lea.
We've found it's something in our 'attributes' - sorry!!
We've started to add this code to our attributes under Twitter/Facebook meta tags:
This stops the pagePath spitting out in the Page Details area. It was this that was causing the problem - removing the type="hidden" will fix it I think but then it displays in the Page Details area.
How should we best do it? Is it something we just shouldn't be calling in attributes? It's just a tidy way to do it that's all...
Thanks, Lea.
I'm completely unclear as to what you're asking, sorry. What's going wrong?
Sorry my fault, found a problem, thought I'd fixed it but not quite. So, to start again:
We noticed some navigation links weren't appearing in the nav. Since emailing I found that the problem wasn't with the nav or the template itself. We discovered that the links only broke to pages that we had renamed in Perch (i.e 'Home page' to 'Home'). So this lead us to think it may be something we've added to page attributes.
So, in page attributes we have a Facebook and a Twitter template:
We've discovered that removing the line including <perch:pages id="pagePath" type="hidden" /> has fixed the problem (the nav now works) but we're unsure as to how to get a URL into these Facebook/Twitter meta areas without it adding that as a region of page attributes in Perch (which could cause problems for users). Type hidden should work (and does), but only if we don't change the pages name.
Basically it won't accept type="hidden" as when we change the pages name it messes up the nav...
I'm still not sure that's any clearer!
Ok, so
pagePath
is an ID already in use by the navigation - if you add a field with that path, Perch will use your data instead of its own and the link won't work.A workaround would be to use two templates. Use one for output, and only include the
pagePath
tag in that one.