Forum
Require sub navigation to display on all levels
I have a working pages template that has a sub-navigation which dynamically link to its relevant child page. i.e. add a new sub-page in Perch and the navigation creates a link to that child page. What I need to happen though is that the child page needs to display the sub-navigation on it's level. Is this possible and how?
here is the page template :
<?php include($_SERVER['DOCUMENT_ROOT'].'/perch/runtime.php'); ?>
<?php perch_layout('global.header'); ?>
<?php perch_pages_navigation('navigation'); ?>
<?php perch_content('Page Style'); ?>
<div class="main-content">
<div class="container">
<div class="sub-page-row w-row">
<?php perch_pages_navigation(array(
'levels'=>0,
'template' => array('subnav.html'),
'from-path' => '*',
)); ?>
<div class="column-bare w-col w-col-9">
<?php perch_content('Blocks'); ?>
</div>
</div>
</div>
</div><img class="tg-on-pages triangle-graphic" sizes="25vw" src="/images/triangle-graphic.png" srcset="/images/triangle-graphic-p-500.png 500w, /images/triangle-graphic-p-800.png 800w, /images/triangle-graphic-p-1080.png 1080w, /images/triangle-graphic.png 1128w">
</div>
<?php perch_layout('global.footer'); ?>
the sub-nav template:
<perch:before>
<div class="column-bare w-clearfix w-col w-col-3">
<div class="subnav w-clearfix" id="subnav" role="navigation"></perch:before><a class="subnav-link" href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
<perch:after>
</div>
</div>
</perch:after>
and my diagnostics:
Perch: 3.0.8, PHP: 7.1.1, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (3.0.8), assets (3.0.8), categories (3.0.8), perch_blog (5.5.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Applications/MAMP/htdocs/perch
PERCH_CORE: /Applications/MAMP/htdocs/perch/core
PERCH_RESFILEPATH: /Applications/MAMP/htdocs/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
HTTP_HOST: localhost:8888
DOCUMENT_ROOT: /Applications/MAMP/htdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Essentially what I'm trying to do here is create a dynamic subnav on level1, but also then display that same dynamic subnav, one level down in level2.
I have been trying different array options but nothing seems to be working so far:
By 'same' do you mean the same set of links from the parent? Or the child links of the current page?
The child links of the current page . Just to be a little clearer, here is a rough breakdown.
Motor (toplevel parent) ---- apply online (sub level child) ----- meet the team (sub level child) ----- terms (sub level child)
The motor page displays each of these 3 child links, but I also need each of these child links to display on the sub level pages. So when I'm down at the apply online level, the same 3 links are still available.
Have you tried
'siblings' => true,
Simon! that fixed the issue at the child level.... However, when I'm back at the top-level (i.e. Motor) I see all of Motor's siblings. I need to have Motor's child links at this level instead. Would I need a separate template?
Okay, so I have it working. What I have done to overcome this was issue was to have 2 sub-level templates; sublevel-1 & sublevel-2 'include-parent' => false (on sublevel-1) 'include-parent' => true (on sublevel-2)
thanks for your help.
Good stuff :)