We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25829
    • 17 Posts
    I’m sure there’s really something simple I’m missing, so I’m sure this’ll be an easy one...

    I have a blog set up on my site with Ditto. Works great so far, but I’m trying to to have an image show up on the page that shows summaries of all the posts. So my ditto call looks like this:

    [!Ditto? &parents=`7` &tpl=`blogtemplate` &display=`4` &paginate=`1` &paginateAlwaysShowLinks=`0` !]

    [+previous+] [+pages+] [+next+]

    So that’s calling a chunk (blogtemplate), with the following code:

    <h3><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
    <p class="blog-summary">[+introtext+]</p>
    <a href="[+url+]">read more ></a>

    So how can I set it up so that I can have an image show for each blog post on the summary page (the page that shows the summary, title, etc). I’m sure a TV is in order, but I just can’t think of a way so that each post can have a unique image when showing on the same page.

    Hope that makes sense, kinda tough to explain.

    Thanks!

      • 33337
      • 3,975 Posts
      create a new image tv, upload image into it. Then call it in your template like [+yourimage+]
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 25829
        • 17 Posts
        I tried that. But then you’ll have the same image for every blog summary.

        Since it’s showing 4 summaries per page, I need a unique image for each summary.
          • 3749
          • 24,544 Posts
          Do you want a different random image for each summary, or do you need to connect a specific image with a specific summary?
            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
            • 25829
            • 17 Posts
            A specific image. For example, if the blog post was about a Camaro, I’d have an image of a Camaro by the summary. Then if the next one was about a Mustang, that one would have a picture of a Mustang. And so on.

            Thanks for the help!
              • 10449
              • 956 Posts
              I think there’s a slight confusion about the term "template" here:

              What zi meant, was to add the image-TV to your chunk that serves as a template for your Ditto-call, i.e. &tpl=`chunkname`.
              If you add a TV to a Ditto-tpl chunk, use placeholder syntax: [+foo+]
              Adding a TV to a "regular" (document-) template needs the syntax [*bar*]

              Of course, adding that image-TV to the regular template won’t do what you’re after. Add it to your Ditto-tpl-chunk instead.
                • 25803 ☆ A M B ☆
                • 721 Posts
                What I do is set up a template variable, in my case, featuredimage with an input type of image.

                In my Ditto call I include this: &hiddenFields=`featuredimage`

                In my Ditto Template for the summary this:

                <div class="more-entries">
                <a href="[~[+id+]~]" title="[+title+]"><img src="[+featuredimage+]" width="75" class="fl" /></a>
                <div class="featuredsummary">
                <h3><a href="[~[+id+]~]" title="[+title+]">[+title+]</a></h3>
                <p>Categories: <em>[+tagLinks+]</em></p>
                <p>[+summary+]</p>
                <p class="read-more">[+link+]</p>
                </div>
                </div>
                
                  • 33337
                  • 3,975 Posts
                  Thats correct. Though if you are using latest ditto, 2.1+ you don’t need to add &hiddenFields anymore.

                  Just edit your blog posts, and use separate images for them. Ditto will output what you select there.

                  Hope it helps.
                    Zaigham R - MODX Professional | Skype | Email | Twitter

                    Digging the interwebs for #MODX gems and bringing it to you. modx.link
                    • 25829
                    • 17 Posts
                    Thanks for the help! I was able to get it working.
                      • 33337
                      • 3,975 Posts
                      You are welcome.

                      Feel free to post whenever you need MODx help. smiley
                        Zaigham R - MODX Professional | Skype | Email | Twitter

                        Digging the interwebs for #MODX gems and bringing it to you. modx.link