We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38175
    • 48 Posts
    I am trying to use getResources to retrieve some content from a child resource. Everything works except the image assigned to the tv.news_thumb template variable.

    Here is the getResource call.

    [[!getResources?
    &parents= `[[*id]]`
    &tpl= `news_list_output`
    &limit= `10`
    &sortdir= `ASC`
    &includeTVs= `1`
    &processTVs= `1`
    &showUnpublished= `1`
    &includeContent= `1`
    &depth= `0`
    &sortby= `menuindex`
    ]]


    Here is the news_list_output template.

    <h2>[[+longtitle]]</h2>
    <img src= "[[+tv.news_thumb]]">
    <p>[[+introtext:ellipsis=`200`]]</p>


    Any ideas why it's not picking up the image? The child resource is unpublished. Thanks.

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 36624
      • 535 Posts
      debug : Don't put a tpl and look at the array output. Can you see your tv ?
        CTRL+SHIFT+U - Clear Cache
        CTRL+SHIFT+H - Hiding Heft Panel
        CTRL+SHIFT+N - Fast Create Resource
        CTRL+ALT+P - Preview Recource (in edit resorce window)
        CTRL+ALT+S - Save
        • 38175
        • 48 Posts
        By taking out the tpl, it does pull in the tv.
          • 38175
          • 48 Posts
          Removing the tpl does get the tv image.
            • 36624
            • 535 Posts
            Quote from: scottmccullough at Nov 27, 2012, 02:34 PM
            Removing the tpl does get the tv image.

            try this :

            [[getResources?
            &parents= `[[*id]]`
            &tpl= `news_list_output`
            &limit= `10`
            &sortdir= `ASC`
            &includeTVs= `1`
            &includeTVList= `news_thumb`
            &processTVs= `1`
            &processTVList= `news_thumb`
            &prepareTVList=`news_thumb`
            &showUnpublished= `1`
            &includeContent= `0`
            &depth= `0`
            &sortby= `menuindex`
            ]]


            if it doesn't work :
            can you copy the array output here ?
            have you looked at the html source to see the output ?
            can you confirm that the tv output type is "text" and are you sure the name "news_thumb" is correct?

            Tips: never use getResources uncached tag, and &includeContent=0 if you dont output the [[+content]].
              CTRL+SHIFT+U - Clear Cache
              CTRL+SHIFT+H - Hiding Heft Panel
              CTRL+SHIFT+N - Fast Create Resource
              CTRL+ALT+P - Preview Recource (in edit resorce window)
              CTRL+ALT+S - Save
              • 38175
              • 48 Posts
              Same result. There is something about the output tpl. If I take the tpl out of the getResource call, the array outputs the image. Put the tpl back in and the image disappears.
                • 29597 ☆ A M B ☆
                • 350 Posts
                Did you try:

                <h2>[[+longtitle]]</h2>
                <img src="[[+news_thumb]]">
                <p>[[+introtext:ellipsis=`200`]]</p>
                
                  MODX Ambassador (NL) | Responsive web design specialist, developer & speaker
                  DESIGNfromWITHIN, MPThemes and Any Screen Size
                  Follow me on Twitter | Read my blog | My code on GitHub
                  • 36624
                  • 535 Posts
                  yeah and you can try to output the tv without the <img> tag to see what you get.
                  at this point if you didn't give us some code to check (output or url) we can't help more..
                    CTRL+SHIFT+U - Clear Cache
                    CTRL+SHIFT+H - Hiding Heft Panel
                    CTRL+SHIFT+N - Fast Create Resource
                    CTRL+ALT+P - Preview Recource (in edit resorce window)
                    CTRL+ALT+S - Save
                    • 38175
                    • 48 Posts
                    I will try taking the tv prefix out. Is there something in the tv input/output settings that I should consider? I have them both set as Image type.
                    • discuss.answer
                      • 36624
                      • 535 Posts
                      Quote from: scottmccullough at Nov 28, 2012, 09:19 AM
                      I will try taking the tv prefix out. Is there something in the tv input/output settings that I should consider? I have them both set as Image type.

                      output should be TEXT not image. otherwise you are making something like this :

                      <img src="<img src="">"> and the image will not show..
                        CTRL+SHIFT+U - Clear Cache
                        CTRL+SHIFT+H - Hiding Heft Panel
                        CTRL+SHIFT+N - Fast Create Resource
                        CTRL+ALT+P - Preview Recource (in edit resorce window)
                        CTRL+ALT+S - Save