We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26834
    • 22 Posts
    I want something that sounds quite simple, but is actually quite complicated to do. Well, I haven’t found a way to do it anyway.

    Basically, I have a menu system like this:

    Level 1
    Level 2
    Level 3
    Level 3
    Level 3
    Level 2
    Level 3
    Level 3

    I want wayfinder to only display the relevant Level 2 and Level 3 links for the page. For instance, if I was on the last level 3 page of the last group, I would only want to see the level 2 parent and the other level 3 link, not the other level 2 and its children. Is there a way of getting wayfinder to use a different parentid depending on what page it is on? Can it tell which is the parent of the page it is on and use that as the startid?

    Thanks.
      • 3749
      • 24,544 Posts
      Have you tried using &startId=`[*parent*]` in the Wayfinder call?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 26834
        • 22 Posts
        No I haven’t, that’s a very good point!
          • 26834
          • 22 Posts
          That worked great on the Level 3 pages, but when on the level 2 pages I still want to display that and its children. I’m not quite sure how I can do this. I can’t set the startid to a certain id as it all Level 2 pages have to use the same template, and I can’t use Parent because that would be the Level 1 page which will display all pages.

          Thanks for your help.
            • 4172
            • 5,888 Posts
            When you need different wayfindercalls on different levels you can make
            chunk1 with: &startId=`[*id*]`
            chunk2 with: &startId=`[*parent*]`

            and use this snippet to call the chunk you need at different levels
            <?php
            //
            //GetChunkByLevel
            //
            //[[GetChunkByLevel? &chunks=`,,,@CODE<h4>Aufgaben:</h4>,@CODE<h4>Subaufgaben:</h4>` &debug=`0` ]]
            //[[GetChunkByLevel? &chunks=`chunk0,chunk1,chunk3,projectlist,projectlist` &debug=`0` ]]
            
            $chunks_arr = (isset($chunks))? explode(",",$chunks) : array(); // [ array ]
            $debug = (isset($debug))? $debug :0;
            
            
            $current_level = ( count( $modx->getParentIds( $modx->documentObject['id'] ) )+1 );// von Stefan
            $output=$chunks_arr[$current_level];
            
            if ($debug == '1'){
            echo 'current_level '.$current_level.' ';
            echo 'chunk '.$output;
            }
            
            if (substr($output,0,5) == '@CODE'){
            $output = trim(substr($output,5));
            }
            else {
            $output= "{{".$output."}}";
            }
            
            return $output;
            ?>


            call it with:
            [!GetChunkByLevel? &chunks=`chunk0,chunk1,chunk2` &debug=`0` !]


            Bruno
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 27374
              • 6 Posts
              GetChunkByLevel isn’t a very good solution.
              There is a more suitable snippet called Something Parent which you can use for your id=`` parameter.

              Do a search on something like "wayfinder submenu parent". There should be several threads on this very same problem already.

              P.S. try searching before posting new
                • 26834
                • 22 Posts
                Thank you for everyone’s help, I’ve got it sorted now.
                  • 16183
                  • 1,390 Posts
                  Quote from: sg1psychopath at Jan 22, 2009, 04:29 AM

                  Thank you for everyone’s help, I’ve got it sorted now.

                  @sg1psychopath

                  Glad you got it sorted.

                  It’s always good to post your solution in the forums though - so that you can help the next person with a similar problem. Hope you don’t mind, thanks.

                  cheers/k
                    • 20413
                    • 2,877 Posts
                    @Bruno: THANKS!!! Very useful!!!!! smiley
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                      • 3749
                      • 24,544 Posts
                      I’m not exactly sure what you want, but combining &startId=`[*parent*]` and &level=`1` or &level=`2` might work.

                      Barring that, I think modifying Bruno’s snippet so it just returns the number without using chunks would be more efficient.

                      &startId=`[[mySnippet]]'


                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting