We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11975
    • 2,542 Posts
    Hi,

    have a look at the PHx plugin

    http://wiki.modxcms.com/index.php/PHx#Conditional_operators

    :-)
      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
      • 6726
      • 7,075 Posts
      I have tried this for the first time with multiple calls but it doesn’t work (neither cached nor uncached)... any way to make this possible ?

      I’d like to avoid using PHx...
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 21112
        • 156 Posts
        I’d like to use this snippeton my site and I think it’s the tool I need for the job at hand, but I don’t have enough programming skills to be confident enough to know what I’m doing.

        I’d like the snippet to check to see if the pub_date year is equal to the current year, and if not, display a chunk which will output: "(pub_date year) Archive" to put in the heading of the page. I’ve sorted documents into categories by year, but they are all displayed using the same template. I don’t want the "200x Archive" message to appear when the date of the document shown is that of the current year.

        Is this snippet, used with a TV the right way to do this? If so, how would I go about that? I’ve never created a TV before and I’m a little overwhelmed by the complexity (and thus I assume power) of TVs as described in the documentation.

        Thanks for your help in advance!
          • 6726
          • 7,075 Posts
          I think if you want to do that, you’ll need to install PHx and use the conditionnal operators, I don’t think you can do that with TVcnd...
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 16879
            • 87 Posts
            Great snippet Mark - what’s the syntax for evaluating against a "null" value - i.e if tv is not empty?
              • 7971
              • 263 Posts
              Hi,

              a great work.
              I had a litte Problem with the syntax.
              I try this syntax to check is a TV is empty or not:
              [!tvcnd? &tv=`tvnews_file` &cnd=`, 1` &rtn=`tpl_news_file`!]
              


              But that did not work.
              Can you tell me how can a check if a TV is empty or not?
                • 6726
                • 7,075 Posts
                Quick fix : set a default value for the TV, such as "blank", therefore when the TV has not been given any value by the user it has blank assigned.

                Now I don’t know if TVCond has the empty value built in...
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 16879
                  • 87 Posts
                  I’ve experimented with PHx and this seems to offer more flexibility for what I need to achieve; basically hiding and showing chunks dependent on whether TV’s have values assigned or not.

                  One thing I did discover is that PHx doesn’t seem to need installing as a standalone plugin with Modx 0.9.6 when Jot is installed.