Forum

Thread tagged as: Question, Runway

Menu template does work on third level pages?

Hi,

On my site, I have a structure as follows:

Library services - Top level

In-house services - Second level

Computers and wifi - Third and last level

There are no drop-down lists from the main menu. Instead, when you land on a page which has subpages, there is a menu on the page, leading you either to the second or third level. My issue is that the menu box appears on top and second level, but not the third?

The code:

pages / menupage.php

<?php
// Site global head content + page title
perch_layout('global/page-head', array(
      'title'=>perch_pages_title(true),
  ));

// Site global header
perch_layout('global/header');

// Standard layout
perch_layout('standard-with-side-menu');

// Site global footer
perch_layout('global/footer');
?>

layouts / standard-with-side-menu.php

<section class="standard fit">
  <section class="std-menu-content">
    <div class="std-menu-container">
      <? perch_content('Content'); ?>
    </div>
  </section>
  <?php perch_pages_navigation(array(
      'template' => array('subnav-level1.html', 'subnav-level2.html', 'subnav-level3.html'),
      'from-path' => '*',
      'levels' => 1,
      'include-hidden' => false,
    ));?>
  <? perch_content('Sidebar'); ?>
</section>

navigation / subnav-level 1, 2 and 3 are all the same

<perch:before>
  <section class="page-menu">
    <aside class="side-menu">
      <ul>
</perch:before>
        <li><a href="<perch:pages id="pagePath"/>"><perch:pages id="pageNavText"/></a></li>
<perch:after>
      </ul>
    </aside>
  </section>
</perch:after>

Obvously I've made sure all pages are using the Menusub masterpage.

Thanks in advance

Grant Smith

Grant Smith 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If the templates are all the same, why do you have 3? Have you tried with just one?

Hi,

I take the point and have changed to the following:

  <?php perch_pages_navigation(array(
      'template'                 => 'subnav-level1.html',
      'from-path'               => '*',
      'levels'                      => 1,
      'include-hidden'      => false,
    ));?>

However, the issue is still unresolved. I think this has something to do with being on the bottom level of my navigation. If I understand this correctly, my menu is displaying the next level down of pages, which is exactly what I want for levels 1 and 2. However, on a level 3 page, I need to show the other pages listed on the same level.

This is menu structure in the hope it helps visualise the structure.

Top level menu (menu shows)

  • Level 2 (menu shows)

-- Level 3 (no menu)

Thanks again

Drew McLellan

Drew McLellan 2638 points
Perch Support

I really don't follow at all. What do you mean by menu? Is there some JavaScript involved?

Hi,

Sorry for not explaining myself well enough.

Each page has a side menu, screenshot below.

screenshot of menu

The above example is an image of a second level page (In house services):

Library services (Top level)

  • In house services (Level 2)

-- Computers and wifi (Level 3)

The below screenshot is the Computers and wifi page, there is no side menu appearing

screenshot of menu

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does this give you?

<?php perch_pages_navigation([ 
    'template' => 'subnav-level1.html', 
]);?>
  <?php perch_pages_navigation([
      'template'                 => 'subnav-level1.html',
      'from-path'               => '*',
      'levels'                      => 1,
      'include-hidden'      => false,
    ]);?>

Produces exact same result as before, no menu on level 3.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Grant,

Since the third level is the last level, then there will be no more sub-pages to display. 'from-path' => '*' means from the current page. If the current page doesn't have any sub-pages, nothing will be displayed.

Thanks,

This is what I figured, so is there a way around this?

A different template for level three pages perhaps? Doesn't feel very efficient.

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

No need for a new template. You need to modify the options in your perch_pages_navigation().

I think you can use the from-level option here. So perhaps something like this:

perch_pages_navigation([
'template' => 'subnav-level1.html',
'from-path' => '*',
'from-level' => 2,
]);

I haven't tested this, but you can refer to the documentation for more details on the options you can use here.