owzim Posted April 17, 2015 Share Posted April 17, 2015 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? Thanks! Link to comment Share on other sites More sharing options...
Soma Posted April 17, 2015 Author Share Posted April 17, 2015 @owzim It's in there by default "parent". See first option https://github.com/somatonic/MarkupSimpleNavigation#same-with-comments 1 Link to comment Share on other sites More sharing options...
owzim Posted April 17, 2015 Share Posted April 17, 2015 @Soma thanks, that worked. I did not associate the name and description of that config setting with this kind of functionality. Link to comment Share on other sites More sharing options...
ro-bo Posted April 17, 2015 Share Posted April 17, 2015 Hallo, 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) -Home -Level1 --Level2 --Level2 -Level1 --Level2 --Level2 -Level1 --Level2 ...... 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 More sharing options...
totoff Posted April 18, 2015 Share Posted April 18, 2015 Ro-bo See the readme file, section "build a menu using a page array"https://github.com/somatonic/MarkupSimpleNavigation/blob/master/README.md Sent from mobile Link to comment Share on other sites More sharing options...
ro-bo Posted April 19, 2015 Share Posted April 19, 2015 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; break; case 3: $root = $page->parent; break; default: $root = false; }//end switch $sub_nav = $root ? $nav->render($sub_nav_options,null,$root) : false; ..... .... But maybe anyone know a better solutions for this. Thanks! Robert Link to comment Share on other sites More sharing options...
totoff Posted April 19, 2015 Share Posted April 19, 2015 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 More sharing options...
ro-bo Posted April 19, 2015 Share Posted April 19, 2015 @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 More sharing options...
Soma Posted April 22, 2015 Author Share Posted April 22, 2015 @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 More sharing options...
dewwwald Posted April 22, 2015 Share Posted April 22, 2015 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: -home -about -bla -subdomain.example.dev -about sub -bla sub on the site the nav will contain if at example.dev home | about | bla or if at subdomain.example.dev subdomain | about sub | bla sub Link to comment Share on other sites More sharing options...
Soma Posted April 22, 2015 Author Share Posted April 22, 2015 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 More sharing options...
dewwwald Posted April 22, 2015 Share Posted April 22, 2015 Hi somma, sorry about the duplicate, I have revised my post. Clarifying the intent of some words and adding structure stuff Link to comment Share on other sites More sharing options...
Soma Posted April 22, 2015 Author Share Posted April 22, 2015 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 More sharing options...
dewwwald Posted April 22, 2015 Share Posted April 22, 2015 Revised , the question is this: Should what I am getting, which is what I want and expect, be a concern, because the ignored template is the same as the root template, or is this how things should work? Link to comment Share on other sites More sharing options...
Soma Posted April 22, 2015 Author Share Posted April 22, 2015 Looks expected to me. The template!=rss|home doesn't affect root page, only the children. It's the starting point, thus it can't ignore it. 1 Link to comment Share on other sites More sharing options...
owzim Posted April 22, 2015 Share Posted April 22, 2015 Soma, not Somma ... 1 Link to comment Share on other sites More sharing options...
adrianmak Posted April 23, 2015 Share Posted April 23, 2015 The code of he "Advanced example with hooks - creating a bootstrap 2.3.2 multilevel navbar" is put in a template file ? Link to comment Share on other sites More sharing options...
Peter Knight Posted June 1, 2015 Share Posted June 1, 2015 @Soma 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 &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... Nature Geography Astronomy (active) - Solar Systems - Planets (active) - - Mars - - Pluto (current) - - Venus - Black Holes Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted June 1, 2015 Share Posted June 1, 2015 Is not it the "parent_class" option? 1 Link to comment Share on other sites More sharing options...
mr-fan Posted June 1, 2015 Share Posted June 1, 2015 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 1 Link to comment Share on other sites More sharing options...
Peter Knight Posted June 1, 2015 Share Posted June 1, 2015 Guys - you're right. Problem at my end with my list items and formatting didn't help. 1 Link to comment Share on other sites More sharing options...
tekno Posted June 2, 2015 Share Posted June 2, 2015 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 More sharing options...
tekno Posted June 2, 2015 Share Posted June 2, 2015 ahh i made it with $RootPage= $page->rootParent i waste my few hours with it Link to comment Share on other sites More sharing options...
bowenac Posted July 9, 2015 Share Posted July 9, 2015 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 More sharing options...
mr-fan Posted August 20, 2015 Share Posted August 20, 2015 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: https://gist.github.com/somatonic/6258081 Thank you very much Soma i love it! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now