We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8642
    • 28 Posts
    Right now my structure is three levels deep, but that may change to a deeper structure later.

    On every page I need to show the first and second level page links, and if I am on a second level page, I need to show also the child pages of the current page.

    Example:

    page1
    page1_subPage1
    page1_subpage2
    page1_subPage2_subPage1
    page2
    page2_subPage1
    page2_subPage2
    page2_subPage2_subPage1
    page3
    page3_subPage1

    In this example I always want to see page1, page1_subPage1, page1_subPage2, page2, page2_subPage1, page2_subPage2, page3 and page3_subPage1. Always.
    But: the only time I want to see "page1_subPage2_subPage1", is when I have clicked on "page1_subPage2". Same thing goes for "page2_subPage2_subPage1", that menu option should only be visible when I’m on the page "page2_subPage2".

    The only way I’ve found so far is to use a separet Wayfinder call for each of the three main pages (page1, page2 and page3), to build a separate menu section for each of them.

    This is clearly suboptimal, since it means I need to change the template everytime the client decides to add a new page on the top level. I would like to do this with only one single call to WayFinder.

    Does anybody have an idea on how to do this?
      • 22586
      • 74 Posts
      Your problem looks a bit like mine, check out my problem in this dynamic submenu thread. I solved it by programming a custom snippet, but yours is trickier because it also needs to identify in what *level* the user is at everytime.

      Thats what I think at least, I am only a beginner in Modx, so I might be overlooking something.

        • 9426
        • 14 Posts
        You can achieve this by patching WayFinder this way :

        1) in the definition of the snippet (into the modx admin interface) add this at the right place:
        ’hideLevel’ => isset($hideLevel) ? $hideLevel: 2,

        2) in the call of the snippet, you must use
        &hideSubMenus=`true` &level=`0` &hideLevel=3

        3) you must also patch the WayFinder class : for version 2.0, replace the line 65 by
        if (!$this->_config[’hideSubMenus’] || $this->isHere($parentId) || $level < $this->_config[’hideLevel’]) {

        That’s it smiley
        I would like to propose this patch for the next version of WayFinder, how to do it ?
          http://insina.com - Etudier le chinois en Chine - Study chinese in China