We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23094
    • 59 Posts
    I need to display content only where there is no $_GET[’tested_value’]. So, I wrote snippet:

    get_url snippet:
    <?php
    if (!$_GET['tested_value']) return 1;
    ?>
    

    and then put this test code to site template

    [!get_url!]
    [+phx:if=`[!get_url!]`:is=`1`:then=`<p>test</p>`+]
    

    I see first ’1’ displayed so, get_url was correctly returned, but I can;t see ’test’ word. Why doesn’t work this condition?
      • 3749
      • 24,544 Posts
      That snippet will always return 1 because you aren’t returning any other value. Snippets return 1 (true) by default if there is no return statement.

      Try this:

      <?php
      if (empty($_GET['tested_value']) ) {
          return 'Empty';
      } else {
         return 'Not empty';
      }
      ?>
        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
        • 23094
        • 59 Posts
        I didn’t know that default is 1

        Thanks a lot!