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

    I'm probably approaching this the wrong way, but let me explain what I'm trying to do, and see if you have any suggestions for me:

    I have a TV with input option values that include some resource fields, such as [*id] and [*alias]. It outputs the correct values on the individual pages as expected.

    However, I also want to use the same TV in a getResources template to display information in a list of these pages. The problem is that, since I'm using resource fields, in this case they output the values of the current page instead of the individual pages in the list.

    If I change the resource fields [* ] to placeholders [+ ], that solves the problem for getResources, but then on the individual pages, the values are empty. Is there a solution here? Or am I just trying to have my cake and eat it too? What would you do if you wanted to use the same TV in both situations?

    Please let me know if you have any insight. Thanks!
      • 3749
      • 24,544 Posts
      This could possibly work, though it might be a little slow (depending on how many there are) -- use placeholder tags with a +:

      [[+id:ifempty=`[[*id]]` ]]
      


      Here's another way to go that might be a little faster if they are all resource fields (untested):

      Put this at the top of the page:

      [[!setPlaceholders]]


      Create a snippet called setPlaceholders with this code:

      /* setPlaceholders snippet */
      $modx->toPlaceholders($modx->resource, "", "");
      


      The second method sets a placeholder for every resource field.





        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