We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18246
    • 8 Posts
    Hey everyone,

    Hope everyones having a great day/night.

    I have an issue with a Ditto chunk and an image placeholder and I thought I’d ask the gurus for a little help.

    The current website that I’am working on requires a basic blog on the homepage with blog entry summaries that display different thumbnails.

    I managed to implement the blog relatively easy with the only problem being the individual thumbnails.

    When I try to display the relevant thumbnail image on each blog summary. I can’t seem to get the image, saved within a "template variable [*image*]" to display render.

    Ditto Call (Homeage Template)
    [!Ditto? &parents=`3` &display=`3` &paginate=`1` &paginateAlwaysShowLinks=`0` &tpl=`news-summary`!]


    Ditto Chunk
    <div>
    <h3>
    <a href="[~[+id+]~]">[+pagetitle+]</a>
    </h3>
    
    <p><img src="[+image+]" /></p>
    
    [+introtext+]
    
    <span>
    <small>[+date+]</small>
    </span>
    
    <p>
    <a href="[+url+]">Read More</a>
    </p>
    </div>


    Now, if I use [*image*] instead of [+image+]. The image displays BUT it’s not unique to the blog summary/blog entry. The same image displays on each blog entry.

    Any help would be much appreciated. I have been staring at the problems for at least 5 hours. Trying different bits and pieces (JS/PHP/Voodoo/Sacraficial Offerings of Fruit).

    Cheers!
    - Marcin
      • 4172
      • 5,888 Posts
      Now, if I use [*image*] instead of [+image+]. The image displays BUT it’s not unique to the blog summary/blog entry. The same image displays on each blog entry.

      [*image*] shows allways the TV-output of the page where you are (the actual page where you have your Ditto-Call).
      [+image+] this is the right syntax, if you want to display the TV-output for each Ditto-item. It is a placeholder, which Ditto replaces on each iteration with the content of each ressource. What’s your problem, if you use this placeholder?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 18246
        • 8 Posts
        Quote from: Bruno17 at Dec 21, 2009, 01:49 AM

        Now, if I use [*image*] instead of [+image+]. The image displays BUT it’s not unique to the blog summary/blog entry. The same image displays on each blog entry.

        [*image*] shows allways the TV-output of the page where you are (the actual page where you have your Ditto-Call).
        [+image+] this is the right syntax, if you want to display the TV-output for each Ditto-item. It is a placeholder, which Ditto replaces on each iteration with the content of each ressource. What’s your problem, if you use this placeholder?


        Hey Bruno,

        Thanks for responding!

        I have tried using the [+image+] placeholder and for some unknown reason, nothing outputs. So if I use <img src="[+image+]" /> it outputs as <img src="" /> . If I use <img src="[*image*]" /> the path to the image is display but as you know, thats not really what I’am trying to accomplish.

        I have tried the other placeholders and there haven’t been any issues. It’s just when I try to use template variables in Ditto chunks, nothing gets displayed.

        Is the Image TV type right for what I’am trying to accomplish?

        I’am using MODx 1.0.2. If that helps. lol

        Thanks again,
        - Marcin
          • 4172
          • 5,888 Posts
          Is the Image TV type right for what I’am trying to accomplish?
          yes, if want to choose images at backend, when editing page-content you should choose image-TV type.
          for testing you can also choose text and put your path manually in.

          are you sure there is content for this TV?. Did you choose images for these ressources?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 18246
            • 8 Posts
            Hey Bruno,

            I have tried both using plain text in the TV, as well as linking an image.

            I just had another go at it and none of the template variables are showing. Could it be prehaps how I have the site structured?

            For example, at the moment the site structure resembles..

            - Home (index.php) - Calling [!Ditto? &parents=`3` &tpl=`news-summary-ditto-tpl`!] to display latest entries with thumbnails.
            -- News (Container/Folder holding news entries.)
            --- News Entry One
            --- News Entry Two
            --- News Entry Three
            --- ... and so on.

            Using two templates, one for the homepage layout and one for the blog entry.

            Each news entry contains a template variable with a link to a different thumbnail image that needs to display on homepage.

            Bruno, if it’s not too much of a hassle. Could you maybe write a rough breakdown on how you would handle displaying a few blog entries using ditto, based on the structure above?

            Nothing too indepth, just enough to see whether I’am missing something.

            I have seen in other posts that people use Snippets to pass certain template variables around (video/casting ditto tutorial). Is there any chance I’d need to do something similar?

            I think I will give up tonight. Lost more MODxing tomorrow.

            Thanks for the help so far, much appreciated. This is the first time that I have really been stuck on something in MODx and I bet it’s something simple too. lol

            Another *cough* EDIT:
            Ok, just thought I’d check to see whether I could get a single text template variable to work within a Ditto chunk on my local. No luck.

            Just to clarify. The rough formula for getting a template variable to work within a "Ditto template chunk".

            1. Call [!Ditto? &parents=`3` &tpl=`ditto-template-chunk`!] .
            2. Create "ditto-template-chunk" with template variable placeholder [+template-variable-name+] .
            3. Create template variable with a name of "template-variable-name" and assign the TV to the template that makes the [!Ditto.. call?

            Ditto calls chunk template and renders everything according to that, inserting the relevant template variable data where nessecary?

            EDIT:
            Also, would anyone know why calling a snippet via [[snippet-name]] would work and [!snippet-name!] wouldn’t? Could I be dealing with a broken installation or something along those lines?

            Wow, I’m tired. It’s 2am and I still haven’t figured it out. haha
            - Marcin
              • 18246
              • 8 Posts
              Hey guys,

              Third times the charm. Oh and a little bit of sleep.

              The template variables are now working. I ended up checking everything again (ditto call, template chunk, template variables). Removing all unnessecary break lines, spaces, etc and it seems to have solved the problem.

              Once the test Ditto call, template and TV where working, I changed it bit by bit to what I needed.

              Now, what caused my TVs to not display? To be absolutely honest, I have no frign idea. I know that Dreamweaver CS3/CS4 sometimes adds extra break lines which in turn cause problems. In the process of cleaning everything I "might" have removed one or more of these.

              Now to test my uncached snippets!

              Thanks again for the help Bruno and cheers everyone.
              - Marcin