Michael Fillier Posted July 17, 2012 Share Posted July 17, 2012 I think having multiple menus and tree structures is something to consider. It is pretty common for a site to have a main navigation, secondary navigation, user navigation and even footer navigation. Sometimes a site does not conform to a single menu structure. I think multiple menu trees and an api function to pull up the structure of the desired tree would be useful. Link to comment Share on other sites More sharing options...
Pete Posted July 17, 2012 Share Posted July 17, 2012 The only way I could see to do this is create a template that has a Title and Page field - then create a hidden YourMenuName field under a hidden Tools page (or whatever) and start building your menu using this template. It's simply a case then of building your structure using this template, entering the titles and linking them to pages in the site. Rinse as repeat for as many menus as you like. That in fact is pretty much the only way you could build entirely different multi-level menus to your main site structure, and it's also really simple. I might have to like my own post 1 Link to comment Share on other sites More sharing options...
Soma Posted July 17, 2012 Share Posted July 17, 2012 Yes Pete , that's exactly what I did on one site. But I try to avoid this setup. Link to comment Share on other sites More sharing options...
ryan Posted July 17, 2012 Share Posted July 17, 2012 Sometimes a site does not conform to a single menu structure. I think multiple menu trees and an api function to pull up the structure of the desired tree would be useful. Think of ProcessWire's tree like a fractal. There is no difference between multiple trees, and branches within a tree. Both can extend forever in the same way. ProcessWire knows nothing about menus. So what is or isn't a menu is based entirely on what you make it, there are no limits. You can have as many menus, whether structured, or flat (via page references, toggles, etc) as you want. Here are common ways of drawing upon ProcessWire pages for menus, but these are just examples in unlimited possibilities: It's common to relate your first level of pages to your top navigation: $topnav = $pages->get('/')->children; It's also common to relate the children of your first level as secondary navigation (which you might also carry further into the structure for tertiary navigation and more): $subnav = $page->rootParent->children; If you wanted dynamic footer pages, you might create a structure where they will be (whether actual viewable pages or redirects): $footerNav = $pages->get('/tools/footer-nav/')->children; Or you might assign footer links via a multi-page reference field on your homepage template, where you edit your homepage, pluck out the pages you want to appear in your footer (using a PageListSelectMultiple input) and drag to order them. (this would be my preferred option) $footerNav = $pages->get('/')->footer_nav; Or you might just put a checkbox field on every page that says "show in footer", and check the box for the pages you want in the footer. $footerNav = $pages->find("footer_nav=1"); Or you might use a repeater to create a more literal menu with title (anchor text) and the URL it should go to. This is just for starters. Pull away from the rigid thinking of other CMSs and you'll find anything is possible. 2 Link to comment Share on other sites More sharing options...
Pete Posted July 17, 2012 Share Posted July 17, 2012 Yup - technically menus other than the main Nav rarely change. It's not a bad thing to hardcode static menus but I can obviously see why there are occasions you wouldn't want to. Link to comment Share on other sites More sharing options...
jmart Posted April 8, 2013 Share Posted April 8, 2013 Just read a post by Soma at http://processwire.com/talk/topic/1036-markupsimplenavigation/?p=9082 about his MarkupSimpleNavigation module. By passing an option into the options array, you can exclude pages. For example, I have a page called Sitemap (id = 1017) that I want to exclude from the top navigation. <?php $mainMenu = $modules->get("MarkupSimpleNavigation"); $menu_options = array( 'show_root' => true, 'max_levels' => 1, 'collapsed' => true, "selector" => "id!=1017" ); echo $mainMenu->render($menu_options); ?> Then for the footer navigation, I can run the same code as above but just take out the "selector" portion. Now my footer navigation will include the link to "Sitemap". 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