We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32495
    • 3 Posts
    Hi,

    this is my first post in the Modx-Forum. Yes - I`m new to Modx and I like it very much wink
    The last time, I made a lot of sites with the ’phpwcms’ CMS.
    Now I like to make a site with Modx...

    I have a structure like this:

    Menu_1
    --Sub_1_1
    --Sub_1_2
    __Sub_1_3
    Menu_2
    --Sub_2_1
    --Sub_2_2
    __Sub_2_3
    Menu_3
    --Sub_3_1
    --Sub_3_2
    __Sub_3_3

    I like to have a horizontal navigation which shows only the MainMenu ’Menu_1, Menu_2, Menu_3’.
    And a vertical navigation, showing the SubMenu of the selected menu - for example ’Sub_1_2, Sub_1_2, Sub_1_3’.
    The selected MainMenu should be always marked as ’active’, whatever which submenu is selected.
    And the submenu should be generated dynamicly, depending from the active MainMenu.
    A example-site (made with phpwcms) using that kind of navigation (via script): http://www.gcreit.de

    In ’phpwcms’ I had to make my own replacement-tags - I hope, that i don`t have to make my own snippets in ModX again.
    I hope, that I`m not the only one who want to have this kind of navigation...

    Is that possible? I mean, is there a working solution with a script an not with hiding menus via css?


    Thank you for your help and a lot of ’Grüzlils’ from Bavaria

    Andi
      Gleitschirm Taxi - Tandemfliegen im Chiemgau
      www.gleitschirm-taxi.de

      Faszination Berge
      www.mountain-panorama.com
      • 15987
      • 786 Posts
      You can use the dropmenu snippet that is included with your installation, or you can try its replacement wayfinder (get it here: http://modxcms.com/Wayfinder-868.html).

      Wayfinder is still in beta, but has more functionality than the original dropmenu snippet.
        • 7923
        • 4,213 Posts
        You also need the UltimateParent snippet for this. Get that and then for the top menu use snippet call like:

        [!DropMenu? &levelLimit=`1`!] or [!Wayfinder? &level=`1`!]

        and for the side menu, use snippet call:

        [!DropMenu? &startDoc=`[[UltimateParent]]`!] or [!Wayfinder? &startId=`[[UltimateParent]]`!]



          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 32495
          • 3 Posts
          Hi,

          thank you for your help.
          Now it works perfect...

          Grüzli - Andi
            Gleitschirm Taxi - Tandemfliegen im Chiemgau
            www.gleitschirm-taxi.de

            Faszination Berge
            www.mountain-panorama.com
            • 21893
            • 113 Posts
            Hi

            I’m still looking for a possiblity to realize a submenu depending from a topmenu. (In my case a topmenu (5 Items) a secondlevel-Menu (5~6 Items) and then for each secondlevelmenu a lot of sublevels and documents)

            Quote from: doze at Aug 05, 2006, 09:30 PM

            You also need the UltimateParent snippet for this. Get that and then for the top menu use snippet call like:

            [!DropMenu? &levelLimit=`1`!] or [!Wayfinder? &level=`1`!]

            and for the side menu, use snippet call:

            [!DropMenu? &startDoc=`[[UltimateParent]]`!] or [!Wayfinder? &startId=`[[UltimateParent]]`!]



            What I dont get here is: What is the UltimateParent-Snippet needed for? As far as I understood its just given me the absolut parent back, for that I could use just the needed StartID in Wayfinder?

            If I have a secondlevel menu its not helping me, is that right?

            Maybe somebody can help my penny to drop huh

            Nudibranch
              Smile, it confuses people!
              • 7923
              • 4,213 Posts
              Yes, UltimateParent won’t work for you when you have 2 level topmenu and you want only the childs of the second level item to appear..

              Try this:
              $top = isset($top) ? $top : 0;
              $stepback = isset($stepback) ? $stepback : 0;
              $id = isset($id) ? $id : $modx->documentIdentifier;
              if($id==$top || $id==0) { return $id; }
              $pid = $modx->getParent($id,1,'id');
              if($pid['id'] == $top) { return $id; }
              $path = array();
              while ($pid['id'] != $top && $pid['id'] != "") {
              	if($stepback != 0) {
              		array_push($path, $id);
              	}
              	$id = $pid['id'];
                  $pid = $modx->getParent($id,1,'id');
                  if($pid['id'] == $top) { 
              		if($stepback != 0) {
              			$path = array_reverse($path);
              			$id = $path[$stepback-1];
              		}
              		return $id; 
              	}
              }
              return 0;

              In the &stepback parameter, you can define how many levels it should step back in the tree from the ultimate parent. So in your case, it would be &stepback=`1`

              I think that the ultimateparent snippet could be implemented without querying the database in the newest modx version, because there is now a documentMap variable available that has parent child mappings.. But I have not looked at it, so this is just a quick solution.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 21893
                • 113 Posts
                Thank you very much doze,

                i will try this, and i will start to learn php right now.

                :-) a now very busy Nudibranch
                  Smile, it confuses people!