We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5187
    • 14 Posts
    I’m trying to make a submenu on the left side of the website depending on which section the visitor is in. I need to display the parent of the submenu in addition to listing the children.

    Example:

    if the site tree looks like this:

    Home
    About
    - Item 1
    - Item 2
    Products
    - Item 1
    - Item 2
    Contact

    And I click on About or Item 1 underneath it then it would display:

    About
    - Item 1
    - Item 2

    on the left side of the site.

    I have wayfinder working as expected for the children of the ultimate parent, and I have figured out how to get the parent ("About" in this case) to show at the top of the menu list however its pulling the pagetitle (H2) instead of the link.

    Iam using the wayfinder call below:

    [!Wayfinder? &startId=`[[UltimateParent]]` &displayStart=`1` &outerTpl=`sidebar-menu-wrapper` &rowTpl=`sidebar-menu-item` &level=`0` &sortBy=`menuindex`  &hereClass=`current_page_item`!]
    


    I can get the entire site tree to display adding
    &startId=`0`
    however obviously i don’t need every menu item and sub menu to display. I think I’m close however I just can’t figure it out, any ideas? iam using Evo BTW
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you want the start item to be an actual menu URL instead of an H2, you need to juggle the tpls for outerTpl and the startItemTpl.

      Have the startItemTpl start the <ul> container, display the link for the start item, then have the [+wf.wrapper+] placeholder. This will start the UL, make the start item link, and generate the rest of the menu. It can take the same placeholders as the rowTpl. Since it is not a row item per se, it has to have a specific tpl just a little different from the usual rowTpl.
      <ul><li id="startItem" [+wf.classes+]> 
      <a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a> 
      </li>[+wf.wrapper+]


      The outerTpl will skip the opening <ul> tag; it should just be
      [+wf.wrapper+]</ul>


      So the whole menu list structure is started with the startItemTpl which is processed first, then the usual innerTpl and rowTpl and innerRowTpl would be the same, then the outerTpl finishes off the UL.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 5187
        • 14 Posts
        ah perfect.. thanks do much this worked brilliantly! I thought it was related to the templates but I didn’t quite get my head wrapped around it.