We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26849
    • 16 Posts
    Excellent! I will try that tonight then grin

    Thanks Paul
      • 17010
      • 20 Posts
      Hmm.

      This is what I have been trying to achieve for the past few days as well and have not been successful. [[Wayfinder? &startId=`0` &hideSubMenus=`true`]] is not working in that it shows all of the menus at the root level (albeit without their children).

      Using the example presented earlier, if I have

      Home
      About us
      History
      Mission
      Contact us
      Telephone
      Address

      then when I am in the "About us" document, the menu displayed is:

      Home
      About us
      History
      Mission
      Contact us

      I don’t want Home or Contact us to show up and of course don’t want to manually exclude them.

      Pleth can you elaborate on what you did?

      I see the FirstChildRedirect snippet but not a GetField one and in any case have no idea how to use them.
        • 23571
        • 223 Posts
        Okay, bear with me on this one, it seems a little convoluted, but it does work...

        I created a chunk, {{getFieldid}} with the snippet call: [!GetField? &docid=`[*parent*]` &field=`id`!]

        I then created another chunk, {{getFieldpt}} with the snippet call: [!GetField? &docid=`[*parent*]` &field=`pagetitle`!]

        I then created a third chunk, {{getFieldlink}} to contain the combined parent id and pagetitle as a link: <a href="[~{{getFieldid}}~]" title="{{getFieldpt}}">{{getFieldpt}}</a>

        Next, I called in my {{getFieldlink}} above my Wayfinder call, [!Wayfinder? &startId=`[[UltimateParent? &topLevel=`1`]]`!] and then styled the output with CSS.

        Almost forgot, I believe this to be the link to the getField snippet: http://modxcms.com/getField-667.html
          • 17010
          • 20 Posts
          Wow. Appreciate the concise yet detailed instructions.

          I couldn’t get what you did to work for me as it was, but it allowed me to figure out how to make a snippet that does do it for me. The problem was that getFieldid was getting then passing an empty link on to getFieldlink which in turn gave me a blank menu item pointing to nowhere.

          For anyone interested, the snippet is:
          <?php
          $id=$modx->documentObject['id'];
          $fid = $modx->getParent($id,1,'id');
          if(is_array($fid))
          $bingo=implode(" ", $fid);
          if ($bingo != "") {
          $flpt=$modx->getChunk('getFieldpt');
          return "<a href=\"[~$bingo~]\" title=\"$flpt\">$flpt</a>";
          }
          else 
          return "$fid";
          ?>


          Probably not the most optimized code, but like i said, it works; that and two calls using wayfinder and I have the parent and children on all my pages.

          JP
            • 23571
            • 223 Posts
            Now that I look at it I forgot to mention that my solution needs to have all the documents residing within a directory that uses a FirstChildRedirect on the parent and then the 1st document should not be displayed in the menu. I would imagine that was why you were getting a blank from the getField snippet. I told you it was convoluted!
              • 8147
              • 6 Posts
              Well I too required this as I wanted to Make Some simple blog navigation, especially on containers with alot of hidden from menu pages, here is what i did maybe someone could expand on it further.

              Snippets Used (not all are necessary in the end) but they are all 3 good to have in your repertoire, id install em anyways they are tiny and quick to set up.

              GetField 1.3beta - http://www.modxcms.com/getField-1.3-beta-1189.html
              UltimateParent 1.3 - http://modxcms.com/UltimateParent-643.html
              FirstChildRedirect 1.1- http://www.modxcms.com/FirstChildRedirect-1.1-840.html

              Now Continuing in the work of the above posters.......both methods listed here seem to work, however i cleaned it up a bit.

              I created the chunks as per pleth’s post above

              {{getFieldid}} == [!GetField? &docid=`[*parent*]` &field=`id`!]
              {{getFieldpt}} == [!GetField? &docid=`[*parent*]` &field=`pagetitle`!]
              {{getFieldlink}} ==<a href="[~{{getFieldid}}~]" title="{{getFieldpt}}">{{getFieldpt}}</a>

              Regardless of FirstChildRedirect in the parent folder or not, the chunk {{getFieldlink}} was able to return the appropriately titled Parent Link.

              Alternatively, you could use lesur’s Method and create a new snipped called

              [[ParentLink]] ==

              <?php
              $id=$modx->documentObject['id'];
              $fid = $modx->getParent($id,1,'id');
              if(is_array($fid))
              $bingo=implode(" ", $fid);
              if ($bingo != "") {
              $flpt=$modx->getChunk('getFieldpt');
              return "<a href=\"[~$bingo~]\" title=\"$flpt\">$flpt</a>";
              }
              else 
              return "$fid";
              ?>


              This also Returns the same a result as per pleth’s post.

              Which one is cleaner?

              I dunno I’m no expert but they both work.

              Moving on, I created a new Chunk called

              {{BlogNav}}

              This chunk will be used to provide basic navigation between all hidden documents in a single directory as well *only* that document’s immediate parent. This allows you to have navigation between individual pages within a blog without the 99 blog posts form a trip in the main menu, or the clutter of ditto calls on each page yet it still provides the navigation, even if the pages are hidden from the main menu.

              For Instance it will return this, regardless of where the documents reside in the main site’s hierarchy, even if they are hidden:


              • MY Blog
                [list]
                [li]Post1
              • Post2
              • Post3
              • Post 4
              • Post 99
              [/li]
              [/list]

              So to finish it off this is the master chunk you need:

              {{BlogNav}} ==

              <div id="blognav">
              <ul>
              <li>{{getFieldlink}}
              [!Wayfinder? &startId=`[*parent*]` &ignoreHidden=`true`!]
              </li>
              <li>[[ParentLink]]</li>
              </ul>
              </div>

              I used both {{getFieldlink}} & [[ParentLink]] To show it could be done either way or both.

              Now Add some CSS Styling:

              #blognav {
              text-align:center;
              }

              #blognav li, #blognav ul {
              display:inline;
              margin:0px;
              list-style-type:none;
              }

              Now put the {{BlogNav}} call in the bottom of any document or add it to your template and you will get a nice navmenu output in the bottom of your blog post in the same order as your menu sorting within modx...just like i used on my site while i was in Hawaii:

              http://www.mmayukon.ca/training/blogs/mauiblog/mauitease.html

              Side Notes and Ideas for future improvement:

              The next step would be to combine this with pagination or Breadcrumbs somehow. I wouldn’t know how to do that though. Also, Another Interesting Result of this experiment is that I Made another Chunk using getfield that returns the parent 2 steps up from the source documents ID.

              This could also be useful in certain circumstances I think.

              I called it:

              {{DoubleParent}} == [!GetField? &docid=`[*parent*]`&field=`id`&parent=`1`&parentLevel=`1`!]



                • 27374
                • 6 Posts
                Why is this getting so complicated? The original problem is that pleth wants &displayStart to generates <a> rather than <h2>

                The Wayfinder &startItemTpl parameter is dedicated to this problem.

                1: Tell Wayfinder to use your own start_item_template.
                [!Wayfinder? &displayStart=`true` &startItemTpl=`your_custom_start_item_template_chunk`!]


                2: make your_custom_start_item_template_chunk something like this:
                <h2><a href="[+wf.link+]">[+wf.linktext+]</a></h2>[+wf.wrapper+]


                3: Clear cache and test the result
                  • 23571
                  • 223 Posts
                  Thanks. I knew there had to be a simpler solution.
                    • 3540
                    • 5 Posts
                    This is kind of what I am looking for - the only problem I have, is that seeing as I have used &displaystart=TRUE, even where there are no child categories, I get an empty menu

                    [!Wayfinder?startId=`[*id*]` &level=`2` &hideSubMenus=`1` &outerTpl=`dynamicSide` &displayStart=`TRUE`!]

                    any solutions? Basically if there are subcategories to the page I’m on, I want the subcategories in a side nav - if there arent, then I want nothing ot appear there.

                    [!Wayfinder?startId=`[*id*]` &level=`2` &hideSubMenus=`1` &outerTpl=`dynamicSide` &displayStart=`TRUE`!]
                      • 34108
                      • 66 Posts
                      I needed to figure this out to. I found the simplest way was just to turn &displayStart on, then MODx would automatically add in the parent item as a <h2>. For example...
                      [[Wayfinder? &startId=`4` &level=`2` &displayStart=`TRUE`]]


                      ...produces this HTML which you can then easily style.
                      <h2>About</h2>
                      <ul>
                        <li><a href="/test-site/index.php?id=8" title="About Us" >About Us</a></li>
                        <li><a href="/test-site/index.php?id=9" title="Our Vision" >Our Vision</a></li>
                      </ul>


                      I also found the easiest way to control the layout was to wrap a div around each WayFinder call. I did originally try the &outerTemplate variable but just couldn’t get it to work exactly right.
                      <div class="footer-nav">[[Wayfinder? &startId=`4` &level=`2` &displayStart=`TRUE`]]</div>


                      Hope this helps someone.