We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32678
    • 290 Posts
    Trying to accomplish a couple of things in a Wayfinder menu in Revo 2.3.3:

    1) In the below hierarchy, for &categoryFoldersTpl, I'd like to use templateA for ultimate parents and templateB for siblings. I found many examples in which Wayfinder is called as a result of a condition, but none where tpls are switched within a Wayfinder parameter, and cannot get the latter to work.

    Ultimate Parent Category Folder > (TplA)
    --Sibling Category Folder > (TplB)
    ---Resource 1
    ---Resource 2
    --Sibling Category Folder > (TplB)
    ---Resource 3
    ---Resource 4

    I tried both a conditional filter and If within the &categoryFoldersTpl parameter; in both cases Wayfinder defaults to &parentRowTpl.

    I tried the conditional filter or If statement within the &categoryFoldersTpl chunk, in turn specifying chunks for each condition; Wayfinder uses the same ultimate parent (i.e. id=3), and ultimate parent template, for all instances of a category folder, and doesn't output resources in the submenu.

    For context, here's how I tried the Wayfinder call, using either id or parent as the subject of the condition:
    [[Wayfinder? 
       ...parameters...
       &categoryFoldersTpl=`[[[[*parent:is=`3`:or:is=`17:then=`$templateB`:else=`$templateA`]]]]`
    -OR-
      &categoryFoldersTpl=`[[If? &subject=`[[*parent]]` &operator=`EQ` &operand=`3,17` &then=`$templateB` &else=`$templateA`]]`
    -OR-
      &categoryFoldersTpl=`catHeading` // With same output filter / If call in catHeading chunk
    ]]
    


    2) Related to the scenario above, I want to vary the submenu tpl by ultimate parent. Basically, I want to show a monster menu for one site section and a list menu for another. I haven't tried anything with this yet, but suspect its solution will be similar if not identical to the above.

    Any ideas?
      • 4172
      • 5,888 Posts
      I think, you want to change the name of the chunk, not put a chunk itself to the tpl - property

      so try:

      &categoryFoldersTpl=`[[*parent:is=`3`:or:is=`17:then=`templateB`:else=`templateA`]]`


      Do they have all the same template, children of 3 and children of 17?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • For one thing, you don't use chunk tags in Wayfinder properties, just the chunk name.

        For another thing, [[*...]] always refers to the field for the current resource, the one the Wayfinder snippet is on.

        You might be able to use output modifiers in the chunk tpl itself. Your needs are complex enough that I'd be inclined to use custom snippets in the chunk tpl, using the placeholders as property values for the snippet. Use getOption() to get the properties, then use a PHP switch to determine what HTML to return.

        On the other hand, do you really need separate tpls for these? Can you possibly use just one tpl or class, then use specific CSS directives?

        ul li.category (top level - style A)
        ul li ul li.category (second level - style B)

          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
          • 32678
          • 290 Posts
          Quote from: Bruno17 at Feb 22, 2015, 08:35 PM
          I think, you want to change the name of the chunk, not put a chunk itself to the tpl - property

          so try:

          &categoryFoldersTpl=`[[*parent:is=`3`:or:is=`17:then=`templateB`:else=`templateA`]]`


          Do they have all the same template, children of 3 and children of 17?

          Ah, OK. Did not realize I'd need only name the chunk, rather than call the chunk, where using a condition in a parameter. Thanks!
            • 32678
            • 290 Posts
            Quote from: sottwell at Feb 22, 2015, 08:50 PM
            For one thing, you don't use chunk tags in Wayfinder properties, just the chunk name.
            .
            I didn't figure this to be the case when using a snippet or filter within a Wayfinder parameter. Good to know.

            Quote from: sottwell at Feb 22, 2015, 08:50 PM
            For another thing, [[*...]] always refers to the field for the current resource, the one the Wayfinder snippet is on.

            I don't think I fully understand the constrain. The call is in a template used by all resources, which is why I thought parent would work. This applies ONLY to nested site sections where the ultimate parent appears within the menu, and meets the category folder condition.

            Quote from: sottwell at Feb 22, 2015, 08:50 PM
            You might be able to use output modifiers in the chunk tpl itself.

            As described, I tried this but couldn't get it to work.

            Quote from: sottwell at Feb 22, 2015, 08:50 PM
            Your needs are complex enough that I'd be inclined to use custom snippets in the chunk tpl, using the placeholders as property values for the snippet. Use getOption() to get the properties, then use a PHP switch to determine what HTML to return.
            Figured this would be the response. I'm a front end dev with no practical familiarity of PHP.

            Quote from: sottwell at Feb 22, 2015, 08:50 PM
            On the other hand, do you really need separate tpls for these? Can you possibly use just one tpl or class, then use specific CSS directives?

            ul li.category (top level - style A)
            ul li ul li.category (second level - style B)
            The li structure varies by level, and in addition I use unique typicons, which require an html element, to signify menu level. I could use a different icon system and style :after with content property, but that would require too much editing in other areas of the site to be practical.
            • Can you post a link to an example of the menu you are trying to create?
                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
                • 32678
                • 290 Posts
                Quote from: sottwell at Feb 22, 2015, 10:26 PM
                Can you post a link to an example of the menu you are trying to create?
                I'm developing the site locally. If you think there's a feasible solution to the scenario I described that doesn't involve a custom snippet, I can make the site accessible easily enough.
                  • 3749
                  • 24,544 Posts
                  Do you want to use a different row Tpl chunk based on the parent of the page being shown in the menu, or on the parent of the page with the Wayfinder tag? The first one would be quite difficult, the second should be very easy.

                  IOW, will a given menu use different Tpl chunks for different pages in the menu (based on each page's parent)? I can't think of an easy way to do that.




                    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
                    • 32678
                    • 290 Posts
                    Quote from: BobRay at Feb 23, 2015, 07:32 AM
                    Do you want to use a different row Tpl chunk based on the parent of the page being shown in the menu, or on the parent of the page with the Wayfinder tag? The first one would be quite difficult, the second should be very easy.
                    There's something fundamental that I'm not getting. The tag is on a template used by all resources, so I'm unclear on the difference between the scenarios described here. Regardless, I want to show a tpl chunk based on a resource's position in the site tree...that's how I'm thinking of it, anyway. Based on the responses, this isn't the correct way to do so.

                    Quote from: BobRay at Feb 23, 2015, 07:32 AM
                    IOW, will a given menu use different Tpl chunks for different pages in the menu (based on each page's parent)? I can't think of an easy way to do that.
                    Yep, think this is what I'm trying to do.

                    So to summarize the responses so far, the implication is a 'monster menu' approach needs to be used for every applicable site section, meaning that there's no way to present a complex site section differently than a complex site section. Or, stated differently, there is no straightforward way to present a different menu structure and content for one site section versus another.
                      • 22427
                      • 793 Posts
                      [[*parent:is=`3`:or:is=`17:then=`templateB`:else=`templateA`]]
                      The missing backtick after 17 is just a typo here, isn't it?