We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17016
    • 138 Posts
    Is this a bug or did we anything wrong?

    Using this snippet call:
    [[!getResourceField? &id=`1155` &isTV=`1` &field=`imagetv` &default=`test`]]

    we get back the url of the image as defined in the TV imagetv (input options: image).

    But if the TV is empty we only get back "test" when we don´t use &isTV=`1` in the snippet call.

    Can anybody tell if this is a bug or is there anything we might have done wrong? (Using Revo 2.1.1-pl)

    Letti
      • 3749
      • 24,544 Posts
      Do you mean that when isTV is set to `1`, you don’t get the ’test’ value back when the TV is empty? If so, that sounds like a bug.
        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
        • 17016
        • 138 Posts
        Yes that is what I mean. Can anybody reproduce this? If yes I will give a bug report, otherwise we will look if we did anything wrong...
          • 3749
          • 24,544 Posts
          I looked at the code and it’s not exactly a bug, though you aren’t doing anything wrong.

          The snippet will only return the value of the &default property if the TV doesn’t exist, or isn’t attached to the template. IOW, if getting the TV object fails, which it won’t in your case.

          It can’t really test for the TV being "empty" because some TVs might be set to 0, which would evaluate to empty.

          I think your best bet is to either write your own snippet to get the TV value (which would be faster anyway), or use the isempty output modifier in the tag.

            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