We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39589
    • 7 Posts
    Hello,
    I have an image tv field, i'd like to be abble to display the content of this tv for all ressources.
    If my client fill this image tv field id'like the image to automaticaly appear on the home page.

    Exemple: if [[*tv.image]] is filled then <div class="item">[[*tv.image]]</div> appears on homepage.

    I've tried something with getresourcefield, but i have to write the resource's id or parent's id and this is not an option.
    I'd like to find a solution that is abble to select and display on an other page this Tv's content.

    MODX Revolution 2.2.10-pl

    This question has been answered by sottwell. See the first response.

    [ed. note: eskemstudio last edited this post 12 years, 1 month ago.]
      Eskem studio - Identitée visuelle & conception graphique pour PME et PM

      Création de site internet
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There are two ways you could do this.

      You could use getResources with TVs enabled, and use an output modifier in the getResources tpl to only output the image if the TV has an image in it. This would be very slow to process.

      Or you could use a custom snippet to fetch only the TV values directly from the database site_tmplvar_contentvalues. This would be much faster to process.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 39589
        • 7 Posts
        Thank you sottwell, i'm sorry while i was reading my post i thought it was not clear. So i modified it.
        I've tried to find some documentention to select from database but i can't find something clear. I've to say that I am a designer and therefore a very bad coder. But I try very hard. I've tried few things this way but this is definitively not my thing. May i ask you some help ?
          Eskem studio - Identitée visuelle & conception graphique pour PME et PM

          Création de site internet
        • discuss.answer
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          FastField or pdoTools installed with its custom parser (actually the same thing as FastField) you can use a new MODX tag:
          [[#<resourceID>.fieldname]]

          http://rtfm.modx.com/extras/revo/fastfield#fastField-Usage

          It depends on what you are doing. Displaying selected images, or getting all of the images? FasField would be good for getting selected images, while a snippet would do better for getting a list of all of the images.

          A snippet would use the $modx->getCollection('modTemplateVar', <tv ID>); to get all of the resources' TVs, then you can work with the collection object to display its members. Probably would be best to convert it to an array using the $object->toArray() function.
          http://bobsguides.com/revolution-objects.html
          http://rtfm.modx.com/xpdo/2.x/class-reference/xpdoobject/field-accessors/toarray
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org