We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25663 MODX Staff
    • 12,272 Posts
    Thanks for the explanation. Seems like it’s case when a custom version of the snippet is the right thing indeed, or it may make sense for Wayfinder 2.5. Maybe a new splitmenu snippet makes more sense though to keep things simpler and with less bloat.
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 5689
      • 289 Posts
      A new snippet might be a good idea, but wouldn’t there just end up being a lot of "reinventing the wheel" to do so? I mean, if Wayfinder just needs a few simple changes to make it work the same way with split menus, is it worth the effort to rewrite a lot of the same thing? Just thinking out loud. smiley
        I'm learning more about MODx all the time and loving it.
        • 25663 MODX Staff
        • 12,272 Posts
        Wayfinder may in fact be the right solution, but it may also be reaching a point where niche corner cases that solve all problems for everyone wind up in bloated code with everyone having a menu system that doesn’t perform well or scale. I have no idea if this is the case, but it’s a warning sign to be wary of encountering.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 5689
          • 289 Posts
          I understand what you mean. Maybe there’s a way to write a new snippet that works alongside Wayfinder. Although I still can’t think of a way to do that without modifying Wayfinder’s code anyway.
            I'm learning more about MODx all the time and loving it.
            • 25663 MODX Staff
            • 12,272 Posts
            I honestly think a derivative of WF would be the way to go.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
              • 5689
              • 289 Posts
              All right, then maybe in my spare time I’ll start working on doing that. I’ll of course check with the authors to make sure it’s okay with them. laugh
                I'm learning more about MODx all the time and loving it.
                • 5350
                • 16 Posts
                Compeek, thank you very much for your solution. I thought it was a common task to make such a menu, but I have spent several hours to realize that Wayfinder just does not allow me to do what I want.

                It’s kind of strange that &activeParentRowTpl needs to display several levels of the menu to work properly. Hope it will be fixed in the future versions of the snippet.

                Thanks again.
                  • 7231
                  • 4,205 Posts
                  IMO it is overkill to use wayfinder for the top-level menu since it is pretty much a static output with oly the active class changing. Create a smile menu snippet just for this. You can use the same logic as UltimaeParent to make it have the active state. I have done this many times...let me see if I can find a version that I can share.

                  Here is one...in this example you state the ids of the top level menu (and a custom id for individual styling...this was needed for this particular menu).

                  [[MenuBuilder? &docs`1,home|2,about|3,contact` &title=`longtitle`]]

                  doc id 1 will have id=’home’ added to the output, doc id 2 will have id="about’ added...and so on (there are 100’s of ways you could do this differently). Then it uses the UltimateParent snippet to find the top-level parent and apply the active class accordingly. This sort of alternative menubuilder is only a few lines of code.

                  <?php
                  // Build simple list menu based on array of doc ids
                  // sample call: [[MenuBuilder? &docs`1,home|2,about|3,contact` &title=`longtitle`]]
                  
                  $docs = isset($docs) ? $docs : '';
                  $docId = explode('|', $docs);
                  //$activeId = '2';
                  $activeId = $modx->runSnippet("UltimateParent", array("id" => $modx->documentIdentifier, "topLevel" => "1" ));
                  $title = isset($title) ? $title : 'pagetitle';
                  $output = '';
                  
                  $output = "<ul>\n";
                  
                  foreach ($docId as $doc) {
                  	$d = explode(',', $doc);
                  	// get doc parent
                  	$thisDocParent = $modx->runSnippet("UltimateParent", array("id" => $d[0], "topLevel" => "1" ));
                  	// get document title 
                  	$y = $modx->getDocument($d[0], $title, 1);
                  	if(($d[0] == $activeId) || ($activeId == $thisDocParent)) {
                  		$output .= "<li id='$d[1]' class='selected'><a href='[~$d[0]~]' title=\"$y[$title]\"><span>$y[$title]</span></a></li>\n";
                  	} else {
                  		$output .= "<li id='$d[1]'><a href='[~$d[0]~]' title=\"$y[$title]\"><span>$y[$title]</span></a></li>\n";
                  	}	
                  }
                  
                  $output .= "</ul>\n";
                  
                  return $output;
                  ?>


                  Note: this is just an example of the possibilities...this was built for a specific site so it may not be what you need, but it is a good starting point. Hope it helps (and that I understood the question) grin
                    [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&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 25663 MODX Staff
                    • 12,272 Posts
                    Honestly Shane, I think this merits going in the repository.
                      Ryan Thrash, MODX Co-Founder
                      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                      • 7231
                      • 4,205 Posts
                      Quote from: rthrash at Jul 08, 2009, 09:19 AM

                      Honestly Shane, I think this merits going in the repository.
                      Maybe with a few more customization parameters...i’ll see if I can make it more flexible first.
                        [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&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]