Forum

Thread tagged as: Error

Standard Navigation not working

Hi all ,

I Tried the standard navigation function with the template being as follows .

<perch:before><ul class="nav float-right"></perch:before>
            <li class="nav-item"<perch:if exists="current_page"> class="selected"</perch:if>
            <perch:if exists="ancestor_page"> class="ancestor"</perch:if>>
            <a href="<perch:pages id="pagePath">"><perch:pages id="pageNavText"></a>   
            <perch:pages id="subitems" encode="false">
        </li>
<perch:after></ul></perch:after>

The output i get is this .

<ul style="list-style: none">
    <li>
        <a href="/sample">
            sample
        </a>

    </li>

                </div>

Do let me know if im doing wrong here .

Titus Saju

Titus Saju 0 points

  • 2 years ago

Im simply trying to output all my pages into navigation .

As of now i have 2 , which is Home & Sample .

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Titus,

The HTML output you included doesn't seem to match the template. How are you outputting the navigation? Are you specifying the template?

Sorry my bad .

     <perch:before><ul class="nav float-right"></perch:before>
            <li class="nav-item">
            <a href="<perch:pages id="pagePath">"><perch:pages id="pageNavText"></a>   
            <perch:pages id="subitems" encode="false">
        </li>
<perch:after></ul></perch:after>

Output is

  <ul class="nav float-right">
            <li class="nav-item">
            <a href="/sample">sample</a>     
        </li>

I donot understand why the ul tag is not being closed . Also there are supposed to be two pages i.e Home and Sample . THis only shows Sample

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you post your diagnostics report?

Perch Runway: 3.1.3, PHP: 7.2.7, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $, with PDO Server OS: WINNT, apache2handler Installed apps: content (3.1.3), assets (3.1.3), categories (3.1.3) App runtimes: <?php $apps_list = [ ]; PERCH_LOGINPATH: /shades/perch PERCH_PATH: C:\xampp\htdocs\shades\perch PERCH_CORE: C:\xampp\htdocs\shades\perch\core PERCH_RESFILEPATH: C:\xampp\htdocs\shades\perch\resources Image manipulation: GD PHP limits: Max upload 512M, Max POST 512M, Memory: 128M, Total max file upload: 128M F1: 3b606135b33e6a102526838f4152a807 Resource folder writeable: Yes HTTP_HOST: localhost DOCUMENT_ROOT: C:/xampp/htdocs REQUEST_URI: /shades/perch/core/settings/diagnostics/ SCRIPT_NAME: /shades/perch/core/settings/diagnostics/index.php

Update :

When i use the below template for navigation , the error happens :

<nav class="navbar-dark fixed-top border-bottom border-light ">
        <div class="bg-scroll-menu"></div>
        <div class="row">
            <div class="col mobilemenu align-self-center">
                <h4 class="text-center text-white"><i class="fas fa-search"></i></h4>
            </div>
            <div class="col p-4 text-center text-white">
                <h4>Shades Properties</h4>
            </div>
            <div class="col p-3 align-items-center d-flex flex-column mobilemenubtn justify-content-center"><span class="menu-bar"></span>
                <span class="menu-bar mt-1"></span>
                <span class="menu-bar mt-1"></span></div>
            <div class="col-md-7 p-4 menudies">          

                <perch:before>
    <ul class="nav float-right">
</perch:before>
        <li<perch:if exists="current_page"> class="selected nav-item"
     <perch:else>
         class="nav-item"
    </perch:if><perch:if exists="ancestor_page"> class="ancestor"</perch:if>>
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>   
            <perch:pages id="subitems" encode="false" />
        </li>
<perch:after>
    </ul>
</perch:after>

            </div>
            <div class="col-md-2 bg-white text-primary nav-item align-items-center d-flex justify-content-center menudies menu-z font-weight-bold"> <i class="fas fa-comments"></i> &nbsp; &nbsp;Make Enquiry</div>
        </div>
        <div class="mobile-menu">
            <div class="row hidden-lg menu-mobile  text-white pt-4" style="overflow-y: scroll;height:80vh">
                <div class="col-12 pl-3">
                </div>
            </div>
            <div class="position-fixed bg-primary text-white w-100 hidden-lg" style="bottom:0%">
                <div class="gradient position-fixed" style="position: absolute;
        content: '';
        width:100%;
        height:9%;
        left:0%;
        bottom:111px;
        background-image: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(0,0,0,1));
        z-index: 10000"></div>
                <div class="col-12 text-center ">
                    <h5>Call Us | Email Us</h5>
                </div>
                <div class="col-12 text-center py-4">
                    <h5><i class="fab fa-facebook-f"></i> &nbsp; &nbsp; <i class="fab fa-instagram"></i> &nbsp; &nbsp; <i class="fab fa-linkedin-in"></i> &nbsp; &nbsp; <i class="fab fa-twitter"></i></h5>
                </div>
            </div>
        </div>
    </nav>

But when i use just this alone , it works !

                <perch:before>
    <ul class="nav float-right">
</perch:before>
        <li<perch:if exists="current_page"> class="selected nav-item"
     <perch:else>
         class="nav-item"
    </perch:if><perch:if exists="ancestor_page"> class="ancestor"</perch:if>>
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>   
            <perch:pages id="subitems" encode="false" />
        </li>
<perch:after>
    </ul>
</perch:after>

What is the difference in both , i literally couldn't find out .

 <?php
    perch_pages_navigation(array(
        'template' => 'Nav.html',
    ));
?>

Passing the navigation like this .

Drew McLellan

Drew McLellan 2638 points
Perch Support

The entire template will be repeated for each item in the navigation, with the exception of the perch:before and perch:after sections. Those are displayed once, before and after the items respectively.

Yup , I know realize how dumb that question was .