Jump to content



Recommended Posts

Hi Soma,

is it possible to make all parents active of an active child?

Example, active pages in bold.

- page 1

- page 2

--- sub 1

--- sub 2

------ subsub 1

------ subsub 2 (the actual active page)

------ subsub 3

--- sub 3

- page 3

I somehow cannot get the parents to have an active class. How would I do that with the module?


Link to comment
Share on other sites


does anyone know how to realize a navigation with MarkupSimpleNavigation that starts eg. at level 3?

I don't know how to set the starting point for a lower level... :'(

(First Navigation)











I'm looking for something like this (Second Navigation):

---Level 3

---Level 3

---Level 3


addition: The third Level (Level 3) is dependant on the second Level (Level2)...

Thanks for your help!

Link to comment
Share on other sites

Hi totoff,

thanks for your reply. I have already tried this, but there is a problem when level 3 is activated (page on level 3 is the current level) -> level 3 is not displayed!

$root = $page->children('template=xyz_template');

$sub_nav = $nav->render($sub_nav_options,null,$root);

I  have found a  (quick-and-dirty) solution by myself:

// Nav-Level 3;

switch (count($page->parents)) {

case 2:

  $root = $page;


case 3:

  $root = $page->parent;



  $root = false;

}//end switch

$sub_nav = $root ? $nav->render($sub_nav_options,null,$root) : false;



But maybe anyone know a better solutions for this.



Link to comment
Share on other sites

Hi Robert,

$root = $page->children('template=xyz_template');

This defines the children of the current page as root page (presumably level 2 in your site tree if I understood you right). So the pages on level 2 and 3 (in the site tree) should show up in the menu if you have the following options defined:

'show_root' => true,
'max_levels' => 2, 

 If they nevertheless don't render I would first of all check if

$root = $page->children('template=xyz_template');

returns an empty array.

Link to comment
Share on other sites

@totoff thanks, but what i am looking for is, that only pages of level 3 (in the site tree) should appear the in the sub_menu  whether pages from Level 2 (main_menu) or Level 3 (sub_menu) are selected...

Link to comment
Share on other sites

@ro-bo Your solution is the only way to go. I'm using same technique on some sites. I don't think it's dirty, this way it's actually pretty flexible, powerful and simple.

Edit: But I'm open for suggestions on how such cases could be solved differently.

Link to comment
Share on other sites

Hey Somma, I have not read the thread, sorry if I am duplicating content.

I have the Multisite module installed and have the module working perfectly, however I am concerned if my config in MarkupSimple nav might be unexpected behavior.

My options for markup simple nav that is relevant:

- I am ignoring all templates that have the name home

- and show_root=true

ie Options are

<<--edit: add method get root -->>

function getRoot($httpHost) {
$root =  $this->pages->get('name='.$httpHost);
if (!!$root->id) {
  return $root;
  return $this->pages->get('/');

<<--edit -->>

$options = array_merge(array(
    'current_class' => 'menu__item_-current',
    'parent_class' => 'menu__item_-current-parent',
    'outer_tpl' => '<ul class="menu_-primary">||</ul>',
    'inner_tpl' => '<ul class="menu menu__sub">||</ul>',
    'selector' => 'template!=rss|home',
    'show_root' => true,
    'list_field_class' => 'menu__item menu__item_-primary',
    'item_tpl' => '<a href="{url_nav|url}">{title}</a>',
    'item_current_tpl' => '<a href="{url_nav|url}">{title}</a>'
), $options) 

I also have the rootPage being overwritten in the render function like so 

<<--edit: add method get root -->

$modules->get('MarkupSimpleNavigation')->render($options, null, $this->getRoot($this->config->httpHost))

<<--edit -->

, obviously returning a page with template named home.

It works as expected. Rendering the page without errors and returning a navigation containing the sub domain as home, meaning the first page and also the root page using template home, and all other sub pages of said sub domain. Even more It ignores all subdomains on the parent domain. Is this what I should expect?

ie ProcessWire admin tree:





    -about sub

    -bla sub

on the site the nav will contain

if at example.dev

home | about | bla 


if at subdomain.example.dev

subdomain | about sub | bla sub

Link to comment
Share on other sites

I'm not sure I can follow you in all regards. Trying to decifer what you wrote especially the last sentence.

And your post is doubled. :)

Not sure what you mean by ignoring "home" template and what that pages are exactly. And where and how?

Anyway just from a glance, a call like $this->pages->get('name='.$this->config->httpHost)) will always return the page no matter what template, status etc. It's like $page->get(id).

Link to comment
Share on other sites

Sorry that still doesn't do it for me. Still same. If I need more than 5 min to even imagine what you trying to show/say I can't help. Also show some more code like what is $options etc.

Just looking at the last "what you get and how it should be" thing, I don't see anything wrong here. But yes not sure I even understand what the question is.

Link to comment
Share on other sites

  • 1 month later...


Have you plans for  an active/here class? It's different than the current class as it's applied to the parent list items

In MODX Wayfinder, this was called the &hereClass

CSS class for the items showing where you are, all the way up the chain. 
CSS = .active 

So if I was currently on a page called Pluto below, the active classes would be applied as follows...



Astronomy (active)

 - Solar Systems

 - Planets (active)

 - - Mars

 - - Pluto (current)

 - - Venus

 - Black Holes

Link to comment
Share on other sites

There should be no Problem:

Quote from soma page 16:

If I select the service one or two links in the services parent page, the children's class is "active" can I set the parent to "active" too?

Yes you can.

'parent_class' => 'active', // string (default 'parent') overwrite class name for current parent levels
  • Like 1
Link to comment
Share on other sites

hi guys i want to list on a side menu which only contains active pages childrens. page with same template.

if i made $RootPage = $page->parent; and render it with $SideList->render(null,$page,$RootPage) works fine but in services main page lists all sub pages.

if i made $RootPage = $page->children; and render works fine but child pages does not contains same level pages.

i want it on service page menu displays service#1, service#2, service#3

on service#1 page menu displays the same (service#1, service#2, service#3)

or other page on product menu displays (product#1, product#2,product#3)

on product #1 page menu (product#1, product#2,product#3)

i cant do this with same template

Link to comment
Share on other sites

  • 1 month later...

Working on a site and for some reason show root, adds the homepage to the end of the nav? I thought this was prepended so not sure why it is ending up at the end of the nav. Not seeing any options for root position. Any ideas?

Link to comment
Share on other sites

  • 1 month later...

This module is so amazing great!

There is no task of navigation that can't go throw this nice piece of code....

Sorry for this idle post - but i think complimenting is important, too ;)

Jus finished my first MarkupSimpleNavigation with the use of the build in hooks to get a MegaMenu working fine...take me only some minutes until i found this gist:


Thank you very much Soma i love it!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...