We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10208 ☆ A M B ☆
    • 1,780 Posts
    Here's a screenshot of a resource tree with parents and children resources - that should help. I lost the whole post once with the dum backspace and ended up repeating myself a little. Sorry.
      Frogabog- MODX Websites in Portland Oregon
      "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
      Having server issues? These guys have MODX Hosting perfected - SkyToaster
      • 22427
      • 793 Posts
      I found a quite flexible solution, using one template variable and a snippet.

      Create a template variable "in_menu" of Input type Checkbox, give it the Caption "Show in menu:" and these Input Option Values:
      Main==1||Side==2
      Choose Delimiter as the Output type and set the Delimiter value to , (a comma).
      Assign the TV to the template containing the Wayfinder calls.

      Create a snippet "to_exclude" with this code:
      <?php
      //Property $menuNr (possible values: 1 or 2) 
      //Get the TV "in_menu" as object:
      $tv = $modx->getObject('modTemplateVar',array('name'=>'in_menu'));
      //Array of the IDs of all the resources in the tree:
      $all_ids = $modx->getTree(0);
      //A new array to collect the IDs to exclude from the menu:
      $to_exclude = array();
      foreach ( $all_ids as $res_id ) {
          //Get the value of the TV for the resource with ID res_id
          //(Possible values are "1" or "2" or "1,2")
          $value = $tv->renderOutput($res_id);
          //Check if the TV value contains the menuNr
          //If not, add the res_id to the array $to_exclude:
          if ( strpos($value,"$menuNr") === false ) {
              $to_exclude[] = $res_id;
          };
      };
      //Convert the array into a string of comma separated IDs
      //Return that string
      return implode(",",$to_exclude);

      The snippet is called with a value for the property &menuNr (1 or 2). For each resource of the tree the value of the TV is checked. If it does not contain the &menuNr, the ID of the resource will be added to the collection of the resources to be excluded from this menu. The snippet returns a comma separated list of the resources to exclude, as a string. This string is needed as the value for the property &excludeDocs of the Wayfinder call.

      In the template, for the Main Menu you have to insert this Wayfinder call:
      [[!Wayfinder? &startId=`0` &excludeDocs=`[[!to_exclude? &menuNr=`1`]]`]]
      And this one for the Side Menu:
      [[!Wayfinder? &startId=`0` &excludeDocs=`[[!to_exclude? &menuNr=`2`]]`]]

      Now editing a resource in the manager (or adding a new resource) you just have to set the TV "in_menu" to the wanted value, and Wayfinder will automatically adapt both the menus. (The snippet calls have to be uncached if changes of the TV values should show immediately.) [ed. note: ottogal last edited this post 14 years ago.]
        • 41653
        • 18 Posts
        Hi Ottogal

        Many thanks for that.

        I tried that solution but it doesn't work, sorry.

        It simply puts all the items down the left hand side.

        I thought it might be that there was no css reference to 'bul-hmenu' and 'bul-vmenu' but adding that didn't make any difference.

        Is there a missing closing '>' on that script?

        I've included a screen grab.

        Many thanks again

        Keith


          • 41653
          • 18 Posts
          Frogabog

          Your solution seems to be the easiest.

          I moved my pages to 'Top Menu Container' and 'Left Menu Container'.

          The top container had the number 20 so I simply did this in the template:

          [[Wayfinder? &startId=`20`  &outerClass=`bul-hmenu` ]]


          and it worked!!

          Now, unless I stumble on any other problems, this is the easiest strategy that allows my partner to edit stuff herself.

          Many thanks for all your efforts.

          Keith


            • 10208 ☆ A M B ☆
            • 1,780 Posts
            The way Ottogal suggested uses a TV so that you can decide which page/resource will be output into which menu (top or side). It's effective but you also must make sure to tick the radio box for each resource, which is a little more work for the editor/resource creator than just placing the resource under a container.

            Being that the resource tree's structure is where Wayfinder looks to get it's structure, overall it's a good idea to organize your site with containers/parents and sub-resources/children. That way, when you create a new child resource under one of your main level resources, you can easily show sibling menus on those pages by using something like the UltimateParent extra and use the same Wayfinder call globally on any sub-page you want.
              Frogabog- MODX Websites in Portland Oregon
              "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
              Having server issues? These guys have MODX Hosting perfected - SkyToaster
              • 41653
              • 18 Posts
              I agree, Frogabog, it was the extra step of ticking the box. However, many thanks Ottogal for your efforts. Very much appreciated.

              Same to you Frogabog, many thanks.

              Now, can either of you wizards, or anyone else for that matter help me by making top level menu items, such as Paintings and Sculpture, non-clickable?

              I've read and read almost all day and there are so many solutions, none of which I understand.

              I have a pathetic solution which is a blank page but I'd prefer something smarter.

              Any attempts using a weblink going to '#' instead of a document have made the click show the 'Home' page. Not good.

              Any ideas, lovely people?

              Keith

                • 10208 ☆ A M B ☆
                • 1,780 Posts
                Make a new rowTpl chunk for the first level, but remove the <a href> and wf.link parts.
                Set &parentRowTpl to the new chunk, and set &innerRowTpl to the original rowTpl chunk that contains links.


                <li[[+wf.id]][[+wf.classes]]><p>[[+wf.linktext]]</p>[[+wf.wrapper]]</li>
                	
                <li>[[+wf.description]]  [[+wf.wrapper]]</li>


                I haven't tested this, it's just how I'd begin to try it. If there's no link tag in the li, then it can't click. Right?

                Edit: This will affect the entire menu, so I think there's some more parameters to consider for just making one or two li items non-clickable. [ed. note: frogabog last edited this post 14 years ago.]
                  Frogabog- MODX Websites in Portland Oregon
                  "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                  Having server issues? These guys have MODX Hosting perfected - SkyToaster
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  If you want a specific top-level item not clickable, use the &categoryFoldersTpl

                  &categoryFoldersTpl 
                  
                  default: NULL
                  
                  values: name of template chunk
                  
                  description: The categoryFoldersTpl is used when the 
                  item is a folder, and either has the template set to blank 
                  or has rel="category" in the link attributes field. 
                  The children of the item must be displayed for this 
                  template to be used as well.
                  
                  available placeholders: Same as RowTpl.
                  

                  example:
                       <li[+wf.classes+]>[+wf.linktext+]</a>
                               [+wf.wrapper+]
                  </li>
                  [ed. note: sottwell last edited this post 14 years ago.]
                    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
                    • 10208 ☆ A M B ☆
                    • 1,780 Posts
                    Is a blank template clickable this way without category set? Or do you have to set the rel="category" in the link attributes to make it work?
                      Frogabog- MODX Websites in Portland Oregon
                      "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                      Having server issues? These guys have MODX Hosting perfected - SkyToaster
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      If the folder resource has a blank template it should also work. I usually do both wink
                        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