We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37437
    • 147 Posts
    I am working with the most current edition of MODx (0.9.6.3) and trying to use Ditto to post links to recent news items (perhaps the most current 2 or 3 items) on the site Home page, and also have links to all news items display on a separate News page. The following Ditto call is placed on the Home page:

    [!Ditto? &parents=`10` &sortBy=’createdon’ &showPublishedOnly=’1’]]

    Happily, links to the documents that reside in the the specified parent directory do in fact post to the page. I now, of course, want to format the look/feel of the postings, further refine which documents are posted, etc. Alas - I simply do not understand how this should happen. There is a fair amount of discussion out there (and I also have Bill Fernandez’s informative doc), but I still have not found anything that really explains the relationship between the Ditto call and Ditto placeholders and values; explains how to really piece all of this stuff together. (Lot’s of parameters are listed, but a comprehensive discussion that explains (and illustrates via example) the logical relationship between all of these elements seems to be missing.)

    In short, I do not know how to proceed. I suspect that I need to create a Template Variable(s) and chunks (to house CSS) in order to additionally refine the way Ditto operates and formats the output, but I still do not really understand WHY? What exactly is the function of placeholders above and beyond the Ditto call itself? Where do the placeholders need to be created and housed, and what is their logical / functional relationship to the Ditto call?

    If any experienced MODx practitioner would be kind enough to try and provide me with the needed insights here I would greatly appreciate it. I really do like MODx and suspect that I will like it even more once I finally have the critical ’aha’ moment with regards to Ditto.

    Thanks so much.
      • 10449
      • 956 Posts
      To control formatting, you simply use a chunk. This chunk acts as a template for Ditto.

      Parameter: &tpl=`chunkName`

      All regular document placeholders that you would normally use like this: [*pagetitle*] have to be used like this [+pagetitle+] in the Ditto tpl chunk, even your own (optional) custom template variables.
        • 20413
        • 2,877 Posts
        Each MODx document have basic built in _TV’s_: http://svn.modxcms.com/docs/display/MODx096/Document-Specific+Resource+Fields
        TV’s is basically fields you can edit and post content in when right clicking docs in MODx manager.

        As you build the template you are in charge of what document content (TV-fields) that should be called. For instance whan you put [*content*]
        in your template this will go get that content from each doc and print it out here.

        Ditto and snippet placeholders almost do the same thing, but though [*content*] is calling the current doc, [+content+] and such placeholders are set to call content from other docs
        you/snippet define.

        http://ditto.modxcms.com/tutorials/creating-a-custom-template.html
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
          • 3749
          • 24,544 Posts
          Here’s a very basic Ditto tpl chunk. To set it up, I created a new chunk called MyNewsItemChunk and pasted in this code:

             <div class="ditto_summaryPost">
                <h3>[+title+]</h3>
                <div class="ditto_summary">[+summary+]</div>
                <div class="seemore"> <a href="[~[+id+]~]" title="[+title+]">See more about this story . . .</a> </div>
                <div class="postedby">» Posted by [+author+] on [+date+]</div>
            
          </div>
          <hr/>
          


          Here’s the Ditto Snippet call I used with it:

          [!Ditto?startID=`8` &display=`3` &dateFormat=`%d-%b-%y %I:%M %p` &tpl=`MyNewsItemChunk` &extenders=`summary` &debug=`0`!]


          If you start with that, you should be able to modify it to get what you want. smiley
            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
            • 37437
            • 147 Posts
            ganesh, mrhaw, and BobRay:

            THANK YOU! I have made tons of headway and now have properly formatted Ditto output on the Home page of the site being built. As you suggested, I created a chunk which I used to lay out the template and then specified corresponding CSS styles in the site’s stylesheet. I do have a few additional questions though:

            1. I am assuming that I will now be able to create a totally independent, second Ditto call on a different page within the site (i.e. A news page). Is this assumption correct?

            2. What placeholder what I use to include the document ’Long title’ in the Ditto output?

            3. I did not utilize a Template Variable in order to configure and style my Ditto outputs. In what way could I (or should I) invoke TVs when working with Ditto. Basically, what additional functionality or advantages are offered by the use of TVs here?

            Thanks again for the insights; they made all the difference in the world.
              • 20413
              • 2,877 Posts
              (1) Yes

              For multiple ditto calls (on same page) use &id=`whatever` and then use placeholder corresponding to that call... (2) [+whatever_longtitle+]

              (3) TVs can be used for tagging http://ditto.modxcms.com
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 10449
                • 956 Posts
                TVs can be used for much more than just tagging. In fact, the use of TVs is only limited by your imagination.

                Let’s say you have a little product catalogue. Or event-list. The default document fields are not sufficient for that task. You simply add as many TVs as you like,

                e.g.
                productNumber, productCategory, productWeight, productManufacturer
                eventClubURL, eventFee, eventFlyer, eventCity, eventStatus
                etc.

                With Ditto, you could then easily sort the listing by any of those custom fields (TVs), instead of just using the default document fields.
                  • 37437
                  • 147 Posts
                  Thanks again guys. I will need to do additional research into the possible uses of TVs. As for the Longtitle associated with documents, I am still not able to get it to display. Not sure what the ’whatever’ refers to in mrhaw’s posting. (It can’t be the ID to a specific document since the ditto call applies to many individual documents.) Anyway, any more insights on how to get a call to display longtitles would be appreciated.

                  Thanks much.
                    • 37437
                    • 147 Posts
                    I finally managed to get it to work. (Helps if you actually add a longtitle to the documents themselves undecided)
                    But thanks much for your help with this.

                    Another quick question: Is it generally preferable, with a fairly simple Ditto call (i.e. no pagination needs) , to post the call as caching or non-caching?

                    MODx Rocks!

                    Marconi
                      • 20413
                      • 2,877 Posts
                      Built-In-TV placeholder: [*longtitle*]
                      Snippet Placeholder one ditto: [+longtitle+]
                      Multiple Snippet calls placeholder [+donaldduck_longtitle+]
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower