We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23054
    • 62 Posts
    I would like to use the the same template but change the document root during the parsing process (I use DropMenu).

    I have two different menus

    root 1
    -->Home
    -->Submenue
    -->Submenue
    ....

    root 2
    -->(need a link to Home of root 1)
    -->Submenue
    -->Submenue

    I can imagine that the changing of the docroot can be done during the parinsg by a plugin and changing the variable-value for the startDoc-Parameter

    But how to create the link to the Home-item - the menu is automatically generated and I don’t want to copy the home-document within MODx to the second menu (that would be a bad workaround)
      • 7923
      • 4,213 Posts
      What are you actually trying to do? Do you have for example top menu somewhere and you want to build a side menu under each topmenu section? Or multilanguage site? or what?

      The two above are easy to do when using UltimateParent (for top/side menus) or SectionRoots (for multilanguage) snippets in the value of startDoc, like [!DropMenu? &startDoc=`[[UltimateParent]]` ... !]

      If you want the Home link allways be in the side menu, check the "show in menu" off and put the link manually to the template before the dropmenu built menu, so it’s allways there. Or you could do weblinks under the different sections what points to your home page.



        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 23054
        • 62 Posts
        Actually I wrote faster than I thought about it cool
        I want to have two different main menues

        MainMenu 1
        -->Menu 1
        --> Menu 2
        ...
        -->refers to mainMenu 2 and changes the document root to MainMenu 2, when clicked

        Mainmenu 2
        --> refers to MainMenu 1 and changes the document root to Mainmenu 1, when clicked
        --> Menu 3
        --> Menu 4

        I assume the necessary changing of the docroot-ID I can do by some variables in source-code and using a plug-in.

        But actually I am not very sure how I can do that at last.
          • 7923
          • 4,213 Posts
          Still don’t quite understand what you want to do.. You want the menu to change to some other in some section etc? why not just use different startDoc values, possible generated by some other snippet?

          Or do you want that users can change the menu them self on any page by selecting some link? then maybe have 2 separate menus allways and hide/display them with css and javascript.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 23054
            • 62 Posts
            A third try laugh

            I want to use the same template for all documents (otherwise it would be easy but not a good programming style).
            But depending on the current documet the menu shall be a different one.

            In the template there is the following code line
            [[DropMenu?&hereClass=`currentPage`&topnavClass=`menuList`&levelLimit=`2`&removeNewLines=`true`]]


            That means the document root is used in order to create the menu.
            So, when a specific document is called I need information by the parsing process that the menu is going to be created now and so I could change the document root in that case.

            I hope this is more clearly
            • Replace that DropMenu call with a TV maybe named MainMenu. In the TV put the DropMenu call, and specify the &startDoc value. Now you can edit that startDoc value for every page. The @INHERIT binding is very handy here, you only have to edit the parent folders for each child document to have the same menu.
                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