Forum

Thread tagged as: Problem

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.

Lea Chapman

Lea Chapman 0 points

  • 6 years ago

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:

<meta property="og:url" content="<perch:pages id="pagePath" type="hidden" />" />

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.

Drew McLellan

Drew McLellan 2638 points
Perch Support

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:

<!-- Open Graph -->
<meta property="og:type" content="website" />
<meta property="og:site_name" content="<perch:pages id="fb_name" type="text" label="Site Name" divider-before="Facebook" />" />

<meta property="og:title" content="<perch:pages id="fb_title" label="Title" type="text" />" />
<meta property="og:description" content="<perch:pages id="fb_description" label="Description" type="textarea" size="xs" escape="true" count="chars" />" />

<meta property="og:url" content="<perch:pages id="pagePath" type="hidden" />" />
<meta property="og:image" content="/images/meta/meta-logo.png" />
<!-- ./Open Graph -->
<!-- Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="<perch:pages id="tw_site_account" label="Account" type="text" divider-before="Twitter" />">

<meta name="twitter:title" content="<perch:pages id="tw_title" label="Title" type="text" />" />
<meta name="twitter:description" content="<perch:pages id="tw_description" label="Description" type="textarea" size="xs" escape="true" count="chars" />" />

<meta name="twitter:url" content="<perch:pages id="pagePath" type="hidden" />" />
<meta name="twitter:image" content="/images/meta/meta-logo.png" />
<!-- ./Twitter -->

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!

Drew McLellan

Drew McLellan 2638 points
Perch Support

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.