We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13736
    • 345 Posts
    How can I generate a variable second level menu in MODx. Or third level for that matter.

    For example my first level menu might be...

    Home | Products | Resources | About Us

    Then my second level menus might be (somewhere else on the page)...

    Products:
    - Product 1
    - Product 2
    - Product 3

    Resources:
    - Resource 1
    - Resource 2
    - Resource 3

    So from the first level menu if I click on Products, how do I get Wayfinder or whatever to just display the second levels. Whether it be Products, Resources, or others.

    I thought maybe the use of the UltimateParrent snippet might be required, but I couldn’t figure out how to feed the UltimateParrent output into the WayFinder startID tag.


      • 7231
      • 4,205 Posts
      [!Wayfinder? &startId=`[[UltimateParent?]]`!]


      Notice that if the WF call is uncached the ultimateParent needs to be cached, or the other way around. To get to the submenu you may need to add a level setting as well.

      Also in order to get the title (Resources:) take a look at the &displayStart parameter. See the link below for some good documentation on wayfinder parameter.
      http://www.muddydogpaws.com/development/wayfinder/parameters.html
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 13736
        • 345 Posts
        Oh thanks. I was missing the uncached option when I tried it the first time.

          • 13736
          • 345 Posts
          On second thought. I’m still getting something quirky. I’m calling the second and third level menu’s like this...


          
          [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]` &level=`1` &outerTpl=`ap.NavList2.Tpl` &hereClass=`current`!] 
          
          [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`3`]]` &level=`1` &outerTpl=`ap.NavList3.Tpl` &hereClass=`current`!]
          
          


          On home page the second and third levels are hidden (as desired). But, when I open a first level menu item (Services) it brings up second level and third level tiers and fills them both with second level links. Then clicking on a second level link (Instant Searches) will bring up the third level links, again on both tiers. Then for something that’s not supposed to happen at all if you click the third level links it will show the fourth level of links.

          Example:
          http://test.applicantprofile.com

          Menu test path:
          Services > Instant Searches > Statewide Searches > Fourth Level Shouldn’t Show In The Horizontal Tiers

          It’s like the UltimateParent snippet is returning the current document rather than it’s parents. Any idea what’s going on?

            • 7231
            • 4,205 Posts
            UltimateParent may not be the best option here since some pages seem to be deeper than others. Take a look at SectionRoots, you can set a list of possible roots and it cycles up until it finds one.

            http://www.modxcms.com/SectionRoots-493.html

            Getting the right combination of level and parent (toplevel and other settings) right can make your head spin a bit. Sometimes it is tricky to get wayfinder to work just right, but once you get it it will be smooth sailing...with the menu at least.

            BTW - the site looks good.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 13736
              • 345 Posts
              Ok. So UltimateParent is counting up from the current document by however many levels. Rather than finding the top of the lineage and counting down the specified levels. I wonder how hard it would be to upgrade the algorithm to count from either direction.


                • 32074
                • 1 Posts
                I am having the same type of problem but i got ultimate parent working but i also want do display the ultimate parent name above the wayfinder menu

                is there a way using for example getpagetile where id= ultimate parent. to be able to display something like:



                [ultimate Parent Name] Menu

                Products
                -item 1
                -item 2
                Services
                - service 1
                -service 2
                  • 7231
                  • 4,205 Posts
                  You can try using the displaystart parameter.

                  &displayStart
                  default: FALSE
                  values: [ TRUE | FALSE ]
                  description: The displayStart parameter will cause Wayfinder to output the document used as the startId using the template startItemTpl. This parameter only works if the startId is not equal to zero. This functionality was added so that it is easy to add header to submenus.

                  See the template and other info here:
                  http://www.muddydogpaws.com/development/wayfinder/parameters.html
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]