We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Excluding current page from navigation output

Hello,

I am using the following to output navigation on my page:

    <?php
        perch_pages_navigation(array(
            'from-path' => '/mypath',
            'template' => 'mytemplate.html',
            'hide-extensions' => true
        ));
    ?>

Now I would like to exclude the page that I am currently on, from the navigation, is this possible?

Mike

Mike Hendriks

Mike Hendriks 0 points

  • 6 months ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Mike,

One option would be to exclude it in the template with conditional tags:

<perch:before>
    <ul>
</perch:before>

<perch:if not-exists="current_page">
    <li>
        <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>   
        <perch:pages id="subitems" encode="false" />
    </li>
</perch:if>

<perch:after>
    </ul>
</perch:after>

Thank you, Hussein. I was using <perch:if exists="current_page">...</perch:else>...", but it was not working. not-exists works.

Drew McLellan

Drew McLellan 2638 points
Perch Support

</perch:else> should be <perch:else /> or <perch:else>