We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    Hi all. I have set up 2 tv's with an input image and output text as they are used in a template in a getpages call. The template consists of this code:

    <div class="post-[[+id]] post hentry category-latest-news tag-tag3 tag-tag5 tag-tag7" id="post-[[+id]]">
    
    
    </div>
    <div class="entry">
    <h2><a href="[[~[[+id]]]]" rel="bookmark" title="Permanent Link to [[+pagetitle]]">[[+pagetitle]]</a></h2>
    <a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.Factfile_title]]" src="[[+tv.Fact1]]" alt="" width="100"/></a>
    <a href="[[~[[+id]]]]"><img class="alignleft" title="[[+tv.Factfile_title2]]" src="[[+tv.Fact2]]" alt="" width="100"/></a>
    <p>[[+introtext]]</p>
    </div>
    
    <br></br>


    With the help of getpages this returns 2 images with a 100px width from a resource. So for example on my mammals page two resource show both with the title, 2 small images (100px width) and the introtext. When you click the resource to view the full page article Fact1 and Fact2 should show two images with 350px, but they don't (called on the template with [[*Fact1]] and [[*Fact2]]. The only way they will show is if I set the TV's to input image and output image. But if I do this they do not show on my 'mammals' page. I could use different Tv's for the mammals page and the resource page but that would mean doubling the images which I don't want to do as it will take 2x as much memory. Is there anything I can do?

    Regards,

    DS
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The template for the resources themselves also need to have <img...> tags with the TV used to provide the src="" part. All that the text-type TV output widget will return is the relative URL to the image.

      You can also use phpThumbOf or one of the other similar extras to resize the image:
      [[+tv.Fact1:phpthumbof=`w=100&h=100&zc=1`]]

      http://rtfm.modx.com/extras/revo/phpthumbof [ed. note: sottwell last edited this post 12 years, 4 months ago.]
        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
        • 7527
        • 437 Posts
        Hi Sottwell. Thank you so much, that worked perfectly and displays a lot better than I had managed to do it! I tried the same on my actual template where currently the call is:

        <img src="[[*Fact1]]"/><img src="[[*Fact2]]"/>


        as I have two images 350px wide but of differing heights, but it does not show anything. It is not essential but would be nice to see how they display if I can make them the same size. Why would this work in a chunk but not on the main template?

        Regards
        DS
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I think I used the wrong tag there, I'm so used to using the [[#...]] tag from FastField (or pdoTools). That should have been [[+...]].

          [[*Fact1:phpthumbof=`w=100&h=100&zc=1`]]
          should work for the main page template.
            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
            • 19872
            • 1,078 Posts
            I think phpThumbOf has been depreciated recently and pThumb is the new replacement. It is implemented in the same manner for easy adaption.