We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11222
    • 5 Posts
    I have a site which has a destinations section. This page, http://www.diyatravel.com/african-travel-destinations/south-africa/western-cape/cape-town, has a menu on the left. To do this I inserted into the template a snippet. Problem is there are many cities / towns that require the same menu meaning that many templates would be required.

    What is required is some sort of script that can check to see which page / section the users is on and apply the applicable menu. So Cape Town > Cape Town Accommodation, etc and Knysna > Knysna Accommodation.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Create a TV, "start-id" with a default value of @INHERIT.

      In the "cape-town" resource, edit its TV value to be its own resource ID.

      Use a Wayfinder snippet with that TV as its startId value:
      [[Wayfinder? &startId=`[*start-id*]` &level=`1` ... ]]


      If you need to, you can put the entire Wayfinder snippet into a TV (again, with the created TV’s default value of @INHERIT). In that case, the snippet tags would be entered into the TV field for the "cape-town" and other parent resources using its own ID as the startID value:
      [[Wayfinder? &startId=`42` &level=`1` ... ]]
        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
        • 11222
        • 5 Posts
        @sottwell

        Can you give me some examples? I’ve not worked with TVs and if so never called them that so perhaps it’s just a little above me.

        To be more specific, I have currently two, there will be more, sections that each have menus that are specific to them and are required to be dynamic. I’m currently using WayFinder and MODx 0.9.6.3. Two diferent templates are used. One simply doesn’t have a righ side navi but the rest is the same.

        I have a chunk called {{destmenu}}. I have placed this chunk on the templates. The idea was that this chunk would now house some code / script that would allow for the page to be checked and the applicable menu used.

        Added:

        I added in the code [!Wayfinder? &startId=`[[UltimateParent]]` &level=`1`!]. Problem is it now took me to ID 15 when it should have taken me to ID 532 (Cape Town). See attached image. For the Knysna section I need it to go to ID 572. I need it to show every in ID 532 and 572. Keeping in mind that there are many many more to come.

        The first URL is for the section "Cape Town": http://www.diyatravel.com/african-travel-destinations/south-africa/western-cape/cape-town/

        Each section has the following structure:

        Cape Town
        * Accommodation
        * Things to do
        * Tours
        * Adventures
        * Travel Tips
        * Specials
        * Events

        The second URL is for the section "Knysna": http://www.diyatravel.com/african-travel-destinations/south-africa/garden-route/knysna/

        Knysna
        * Accommodation
        * Things to do
        * Tours
        * Adventures
        * Travel Tips
        * Specials
        * Events
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          right. In your case, UltimateParent is not the solution.

          Create a TV. Give it a name, and set it to a type of "text". In the Default Value, put @INHERIT. Check the box for the template that will have this menu.

          Put the Wayfinder snippet (or the chunk with the Wayfinder snippet) wherever you want the menu. In the Wayfinder snippet call, put the TV tags for your TV as the value of the &startId parameter.

          Now, when you edit the parent resources (such as Cape Town or Knysna) edit that TV to have the id of that document. The @INHERIT will cause the children to use the same value.

          If you don’t want that menu on other pages using the same template, don’t put the Wayfinder snippet in the template or a chunk. Edit the parent resource and put the entire Wayfinder snippet call in the TV field, using that parent’s document ID as the startId value. Again, the default @INHERIT will cause the children to inherit the same value. Any other pages using the same template won’t show anything at all.
            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
            • 11222
            • 5 Posts
            I created a TV called [*destmenu*], set it to a type of "text". In the Default Value, put @INHERIT, checked the boxes for the template I want have the menu on. See attachment "TV".

            I put the wayfinder snippet inside a chunk. Below are the various options I considered but I don’t know which to actually use.

            [[Wayfinder? &startId=`[* destmenu *]` ]]
            [!Wayfinder? &startId=`[* destmenu *]` !]
            [[Wayfinder? &startId=`[* destmenu *]` &level=`1` ]]

            Below is the complete code that’s in the chunk.

            <!-- Start of Dest Menu-->
            <div id="destination">
            <h2>Cape Town Menu</h2>
            <div id="fhmenu">
            <p>[[Wayfinder? &startId=`[* destmenu *]` ]]</p>
            </div>
            </div>
            <!-- End of Dest Menu-->

            Now, when you edit the parent resources (such as Cape Town or Knysna) edit that TV to have the id of that document. The @INHERIT will cause the children to use the same value.[/QUOTE]

            The above statement is not understood. Attached is a parent resource, Cape Town.

            Could you please provide me with sample code you feel could best work with the info above?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              In the "parent" document, edit the TV that is for the "destmenu" (it will say @INHERIT, since that is the default) to be the ID of that resource. Now its children will inherit their parent’s value for that TV, so they will be using the same value as the startId for their Wayfinder calls.

              The Wayfinder is fine (although you could make life easier on yourself if you used the &displayStart=`1` parameter to generate the <h2> part automatically)
              <div id="destination">
              [[Wayfinder? &startId=`[*destmenu*]` &level=`1` &displayStart=`1`]]
              </div>


              That would produce a menu structure like
              <div id="destination">
              <h2>Cape Town</h2>
              <ul>
              <li><a href="...">...</a></li>
              ...
              </ul>
              </div>
                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
                • 11222
                • 5 Posts
                There’s still confusion of with regards to:

                In the "parent" document, edit the TV that is for the "destmenu" (it will say @INHERIT, since that is the default) to be the ID of that resource. Now its children will inherit their parent’s value for that TV, so they will be using the same value as the startId for their Wayfinder calls.[/QUOTE]

                I’ve tried replacing the @INHERIT with &startId=`532`, also Id=532 and a couple. Maybe the syntax is wrong. I can’t find anything only that clears things up either.

                Sent @sottwell a PM.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Just 532.
                    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
                    • 11222
                    • 5 Posts
                    Simply inserting the number has no effect (See attachment). I have [[Wayfinder? &startId=`[*destmenu*]` &level=`1`]] in the chunk. The links are all gone. If I change the WayFinder code to [[Wayfinder? &startId=`532` &level=`1`]] I get the menu for the Cape Town section. It seems as if the TV is faulty / not being called.

                    OK, turns out there was a copy and paste typo. The menus are now working as they should.

                    Many thanks @sottwell