We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1705
    • 9 Posts
    I am fairly new to Modx and Ditto but need some help! I have searched and read through the forums with no luck.

    I need Ditto to display documents on one page but with 2 different templates. One set of documents is "Paid Listings" the other is "Free Listings" - each with a different template but on the same page.

    IOW Each different table needs to have a different document displayed inside of it.

    After reading through some other posts I made 2 TV’s for the display page and put in the following default Ditto call:

    [[Ditto? &parents=`2` &tpl=`tpl_listings_paid` &orderBy=`ASC`!]]


    [[Ditto? &parents=`2` &tpl=`tpl_listings_free` &orderBy=`ASC`!]] 


    This is what’s in the two templates:
    `tpl_listings_paid`
    <table class="listing_paid" style="height: 233px;" border="0" cellspacing="0" cellpadding="1" width="780">
    <tbody>
    <tr>
    <td>
    <p><img src="[+listing_image+]" /></p>
    </td>
    <td>
    <p><strong>[+listing_name+]</strong><br />
    [+address_1+]<br />
    [+city+], [+province+]<br />
    [+postal_code+]<br />
    [+phone+]<br />
    [+toll_free+]<br />
    Email:<a href="mailto:[+email+]">[+email+]</a></p>
    </td>
    <td>
    <p>[+introtext+]<a href="[+url+]" target="_blank"><br /></a></p>
    </td>
    </tr>
    </tbody>
    </table>



    and

    `tpl_listings_free`
    <table class="listing_free" border="0" cellspacing="0" cellpadding="1" width="780">
    <tbody>
    <tr>
    <td>
    <p><strong>[+listing_name_free+]</strong><br />
    [+address_1_free+]<br />
    [+city_free+], [+province_free+]<br />
    [+phone_free+]</p>
    </td>
    </tr>
    </tbody>
    </table>


    This is not working. I have 2 documents in the container - one paid and one free. The above outputs the first ’paid’ document then a blank, then second ’free’ document then a blank.

    Hope this makes sense.

    Any help or suggestions would be appreciated.

    Thank you.
      • 4041
      • 788 Posts
      I think the reason you are getting a blank space after each listing is the &parents param, it is actually listing both documents in each call. You can either:

      Change &parents to &documents=`XX` in the snippet calls (change the XX to the ID of the particular document)

      or

      Create a new folder for the free listings and change the &parents ID in the second call.

      You also don’t need the ! at the end of the snippet calls. [[ snippet ]] - denotes a cached call, [! snippet !] is an uncached call

      Hope that helps smiley
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 1705
        • 9 Posts
        Hi Breezer

        Thanks for your reply.

        Option 1 would fix it. But this is a problem... whoever is going to maintain the site will be creating new documents (listings) and there could be 100’s of listings. So I don’t want to be editing the ditto call each time a new document is made.

        Option 2 also a good idea. But the paid listings and free listings have to be on the same page - so same parent document. It’s just the way the client wants the site set up smiley

        Any other suggestions?

        I will fix the! in the call smiley

        Thanks!
          • 4041
          • 788 Posts
          Option 2 also a good idea. But the paid listings and free listings have to be on the same page - so same parent document.
          Actually the listings don’t have to reside under the same parent to be shown on the same page. For example you have the following site structure, with page2 showing the aggregated listings:

          Home
          page1 [1]
          page2 [2]
          paidlistings [3] (folder)
          p-listing1
          p-listing2
          freelistings [4] (folder)
          f-listing1
          f-listing2

          Set the Ditto calls on page2 to reference the ID’s of the paidlistings and freelistings folders as &parents, which should print all the listings on the same page.

          page2 content:
          [[Ditto? &parents=`3` ...]]
          [[Ditto? &parents=`4` ...]]
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 1705
            • 9 Posts
            Thanks Breezer!

            That worked. A simple solution - I think I was over complicating the problem rolleyes