New Community Forums are coming. Watch this space for news.
Subscribe: RSS
  • I have created a rowTpl for Wayfinder and a Template Variable, [+sitemap_exclude+] which can be a 0 or 1.

    If its 1 then this means to hide the entry from the sitemap.

    <li[+wf.id+][+wf.classes+]>
    [+phx:if=`[+sitemap_exclude+]`:is=`0`:then=`[+sitemap_exclude+]`+]
    [+sitemap_exclude+] -- 
    <a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a>[+wf.wrapper+]</li>
    


    The problem is:

    1) If I do this:

    [+phx:if=`[+sitemap_exclude+]`:is=`1`:then=`{{Sitemap_rowTpl}}`+]
    


    Nothing ever appears.

    I am trying to figure out what I am doing wrong with respects to the PHX, I want it to do this:

    1. If the [+sitemap_exclude+] = 1 then show the list-item in my Wayfinder &rowTpl

    But for some reason it doesn’t work.

    What is the correct way of doing this?
    • That’s not a template variable tag, that’s a placeholder tag. If you’ve created a TV, then you need [*...*] tags for it.
        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
      • Hi there.

        Thanks for your reply.

        I tried:

        // Chunk: WF_rowTpl_Sitemap
        // Chunk for the &rowTpl Wayfinder
        [+phx:if=`[*sitemap_exclude*]`:is=`0`:then=`{{Sitemap_rowTpl}}`+]
        


        Sitemap_rowTpl is:

        <li[+wf.id+][+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a>[+wf.wrapper+]</li>
        


        But I still get nothing returned/displayed, even though there should be something there.

        If I put:

        // Chunk: WF_rowTpl_Sitemap
        // Chunk for the &rowTpl Wayfinder
        [+phx:if=`[*sitemap_exclude*]`:is=`0`:then=`[+wf.linktext+]`+]
        


        I get:

        Home About Us Destination Guides Contact Us FAQs Latest Deals 
        


        But I do not get any sub-items, or indeed any of the children living in FAQs, even though there are children that are included.

        // Template Variable: sitemap_exclude
        Radio Options
        Input Option Values: Include==0||Exclude==1
        Default Value: 0
        
        • It doesn’t matter what I do, the Sitemap_Exclude template variable and PHX simply does not pick up the exclude/include value.

          I’ve tried using a snippet to resolve the problem, however I do not understand why this isn’t working properly.

          [edit]

          I’ve tried creating a simple checkbox with the value of "Yes" if it is checked, assigning it to a FAQ child page and then using the &rowTpl to ask whether the value is the default value of "0", and if is it is, then display the child page.

          I’ve tried 3 different ways to get &rowTpl from Wayfinder and PHX to work with template variables and display a child page on an if-else statement and it just won’t have it.
          • I encountered a similar problem and I found the following solution.

            Let’s say that a Wayfinder template chunk contains the following code:
            [+phx:if=`[+template_variable+]`:is=`1`:then=`TV is one.`:else=`TV is NOT one.`+]


            The evaluation fails because the template variable’s value is not yet available in the PHx evaluation context. Try inserting the template variable in a "hidden" place, for example:

            <span="display:none;">[+template_variable+]</span>
            [+phx:if=`[+template_variable+]`:is=`1`:then=`It is one.`:else=`It is NOT one.`+]


            The above worked for me. I am sure that there must be a better way to make the template variable’s value available at the PHx evaluation context...




            • I’ve tried using a snippet to resolve the problem, however I do not understand why this isn’t working properly.
              hey worchyld,

              would you like to share the snippet ... i’m trying to achieve the same smiley

              thanks, j
              • I know this is an old post, but I stumbled across it trying to find the answer to this same problem. Using kal_exan's explanation as to why it doesn't work until the variable's value can be evaluated, I used the variable as part of an undefined class name in the Wayfinder template chunk, like this:

                <li class="myClass [+wf.classnames+] type[+template_variable+]">[+phx:if=`[+template_variable+]`:is=`0`:then=`OPTION A`:else=`OPTION B`+]</li>
                


                'type' is the undefined class that is only used to allow for evaluation of the variable. It would print as 'type0' or 'type1'
                • Hi, after some test I have finally got this working. This is what I have done:

                  1. Create a Template Variable with the following values:
                  TV Name:
                  dropdown-menu
                  TV Description:
                  Show Dropdown Menu?
                  TV Type:
                  DropDown List Menu
                  Input Option Values:
                  Yes==0||No==dropdown-none

                  2. Now add &rowTpl=`chunkname` to your wayfinder snippet call:
                  [[Wayfinder?  &rowTpl=`chunkname` &parentClass=`dropdown`]]


                  3. Now go to "chunkname" chunk and put a code similiar to this one:
                     
                  <li class="[+wf.classnames+] [+dropdown-menu+]">
                  <a href="[+wf.link+]">[+wf.linktext+]</a>
                  [+phx:if=`[+dropdown-menu+]`:is=`dropdown-none`:then=``:else=`[+wf.wrapper+]`+]
                  </li>
                  


                  4. Now, open a resource in the root of your website which has children, set the dropdown for the TV previously created to "No", and then save.

                  MODX will apply a "dropdown-none" class to the <li> tag of that resource, so basically we can hide arrows or whatever we use to indicate that there is a dropdown menu, using just css. The PHx call will also stop the output for the second level of the menu in the html, so we don't have to hide it with css.

                  Important: remember that you have to put [+dropdown-menu+] placeholder before the PHx Call, if you remove it PHx will not work. [ed. note: microcipcip last edited this post 7 years, 3 months ago.]
                  • Important: remember that you have to put [+dropdown-menu+] placeholder before the PHx Call, if you remove it PHx will not work.

                    I never understood why PHx does this. Any ideas?
                    • PHx has its own garbage collection to remove its unused placeholders. Unfortunately it also eats any other placeholders in the document object, and since the MODx parser doesn't get to processing placeholders until after the PHx plugin is run, all placeholders are destroyed. I suspect a flaw in the regular expression that PHx uses in scanning for its placeholders when running its garbage collection routine. It should be possible for that regular expression to leave non-PHx placeholders alone, but I'm not experienced enough at regular expressions to try to figure it out.
                        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