We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15662
    • 10 Posts
    I know this is probably a simple question but I can’t seem to find an answer anywhere in the resources/forum.

    I have two menus, a main menu and a seperate sidebar menu. Each of the items in the main menu are also containers that hold articles. I’d like the sidebar menu to show a list of the related articles based on whatever the current page is. That means that the WayFinder call in the template will need to have a "dynamic" startID (don’t know if that’s the right term)...the StartID for the sidebar menu would change from page to page. I think I’ve seen this done, but can’t figure out how to do it. (Or do I need completely seperate templates for each of these main menu pages?)

    Any help would be greatly appreciated since I’ve been racking my brain on this for awhile now.

    Thanks,

    Kenton
      • 15662
      • 10 Posts
      Okay, after a little more digging around, I think something like UltimateParent will do the trick. But having played around with it a bit, I still can’t figure out how to use it. I’m just using it my WayFinder call like:

      startId=`[[UltimateParent]]`

      But that’s not working for me...I mean it’s not showing my menu.

      Gotta be something simple I’m missing. I’ll look at it again tomorrow when my head is clear but if anyone else has any tips in the meantime, I’d appreciate it. I’m sure this is a pretty common thing I’m trying to do.

      Thanks,

      Kenton
        • 27376
        • 576 Posts
        Quote from: kenton at Mar 04, 2007, 09:13 PM

        Okay, after a little more digging around, I think something like UltimateParent will do the trick. But having played around with it a bit, I still can’t figure out how to use it. I’m just using it my WayFinder call like ...
        Be sure to call the outer snippet uncached like so:
        [!Wayfinder? &startId=`[[UltimateParent]]`!]
        Uncached snippets are parsed AFTER normal ones, so ordering is key to making this work wink
          • 15662
          • 10 Posts
          Alright, well here’s the entire snippet call I’m using:

          [!Wayfinder?startId=`[[UltimateParent]]` &level=`1` &rowTpl=`sidenav` &hereTpl=`sidenavhere` !]

          sidenav chunk:
          <li><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a></li>

          sidenavhere chunk:
          <li class="current"><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a></li>

          Using UltimateParent 1.2, MODx v0.9.5

          But for some reason, nothing shows up in the menu. And I mean NOTHING, not a CSS styling issue or anything. There’s nothing in the actual html code that results from this call. Just blank space where the <li>...</li>’s should be.

          Anyone have this come up before?

          I’m stumped!

          Kenton
            • 25663 MODX Staff
            • 12,272 Posts
            Try this:
            [[Wayfinder?startId=`[!UltimateParent!]` &level=`1`  &rowTpl=`sidenav` &hereTpl=`sidenavhere`]]


            Also, if you just need to go up one level, you could just use the document object like the following:
            [[Wayfinder?startId=`[*parent*]` &level=`1`  &rowTpl=`sidenav` &hereTpl=`sidenavhere`]]

              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 15662
              • 10 Posts
              Ohhhh, okay, I think I might have been confused trying to explain this but I think I got it now after taking a look at Ryan’s suggestion.

              I wanted the sidebar to show all of the 1st-level children of the current page (where the current page is one of the main menu items or one of the sub-pages as people work their way down the tree and deeper into the site).

              So as people click on the main menu items, the sidebar changes to show the sub-items underneath that section. Or they click on one of the sidebar items and the sidebarnav changes to show all the items underneath that one.

              I just added [*id*] as the startId for Wayfinder and that did it. I had to create a different template for the homepage though, since the home page and other main pages are siblings (as opposed to those subpages being underneath the home page). There might be an easier way but I think that’ll do for now.

              Sheesh, what a DUH moment!!! I swear I read the documentation a three or four times but I guess this warrants another look. smiley

              Thanks for the help.

              Kenton
                • 25663 MODX Staff
                • 12,272 Posts
                Glad you got it working. smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me