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

    how can I ask if a TV is empty or not?
    My try:
    [+phx:if=`[*news_file*]`:isnot=``:then=`{{tpl_news_file}}`+]
    

    did not work. It seems like that `` will not be interprated as an empty var (nullstring)
    But how can I do this?
      • 7455
      • 2,204 Posts
      try this
      [*news_file:isnot=``:then=`{{tpl_news_file}}`*]

        follow me on twitter: @dimmy01
        • 7971
        • 263 Posts
        No it did not work. huh
          • 7455
          • 2,204 Posts
          ok this wil work

          [*news_file:len:gt=`0`:then=`{{tpl_news_file}}`*]

          Greets Dimmy
            follow me on twitter: @dimmy01
            • 7971
            • 263 Posts
            No it’s the same. It did’nt work. huh
            But what about the syntax? Were’s the "if...." in your example?
              • 7455
              • 2,204 Posts
              I used this call lots of times and it works great

              it says if the length of the value from the placeholder is greater then 0 then display the chunk, I use this one to show or leave out the introtext markup like this: (maybe the else statement must be used for it to work).

              [*introtext:len:gt=`0`:then=`{{display_introtext}}`:else=``*]

              and this works fine, so if this does not somhow work 4 you than maybe somthing else is wrong, like did you check if the value of news_file is really empty no spaces or default value.

              Dimmy
                follow me on twitter: @dimmy01
                • 6726
                • 7,075 Posts
                Personnally I avoid this issue by defining a default value to my TVs (for example "blank" and then testing empty is quite easy smiley )

                OK I cheat it’s a lazy solution but it works tongue
                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 27376
                  • 576 Posts
                  You might want to try [tt][*news_file:ifempty=`{{isEmpty}}`:else=`{{isNotEmpty`*][/tt]
                  » PHx Documentation
                    • 28173
                    • 409 Posts
                    As dragonlord, I want to test if a TV is empty or not.
                    I tried yours differents answer without succes.
                    I work with MODx 0.9.6 and PHx 2.1.2

                    I have a TV name [*contact*]
                    I tried theses codes :
                    [+phx:if=`[*contact*]`:is=``:then=`empty`:else=`not empty`+]   

                    Result : everywhere the string "empty" appears, whereas somes TV docs are not empty !

                    [*contact:len:gt=`0`:then=`not empty`:else=`empty`*]         

                    Result : once again, the string "empty" appears everywhere, whereas somes TV docs are not empty...

                    [*contact:is=``:then=`empty`*] 

                    Result : ditto....

                    I tried this code too :
                    [*contact:is=`Mr John`:then=`the contact is Mr John`:else=`no contact`*] 

                    I have few docs which have "Mr John" on the TV [*contact*]
                    Unfortunately, the result is "no contact" everywhere sad

                    What’s wrong huh!!!!
                      • 33337
                      • 3,975 Posts
                      Are you sure you checked the System events? Sounds like there could be a problem.
                        Zaigham R - MODX Professional | Skype | Email | Twitter

                        Digging the interwebs for #MODX gems and bringing it to you. modx.link