We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37437
    • 147 Posts
    Greetings. I have done a fair amount of hunting through the Ditto documentation, associated forum postings, and wiki, and I am still pretty unclear as to how I can use Ditto to display news item summaries on the Home page for my site. I am running MODx 0961p2

    This is what I have done thus far:

    1. In the main document tree, I created a news directory to hold all news item documents.
    2. I created a new document to correspond to the first news item and populated the document with the news content.
    3. I placed the new document in the news directory
    3. I placed the following Ditto call within the main site template: [[Ditto?parents=`5` &extenders=`summary`]]

    Although the output for this call does provide a link to the actual News Item document, there is no summary whatsoever. The output also includes the date as well as some notation indicating the the entry was created by the default admin account. All i really want to show up for each news item is a title for the item, a date, a summary, and then a link that allows a visitor to then view the entire news item.

    I get the sense that I am missing some critical ’high-level’ understanding here and it is not coming to me by reading the existing documentation. Any guiding comments, insights, or directions would be greatly appreciated.
      • 29076
      • 615 Posts
      Yes, you need a little more than that.  smiley First of all you need a template, that is a chunk of HTML code to show the Ditto call how to present the data on the website. You call it with &tpl=`yourTemplate` within your Ditto call, and the chunk is stored in the Chunks tab under Resources in the manager-backend.

      Here is an example from the documentation on http://ditto.modxcms.com:
      [[Ditto?parents=`0`&depth=`0`&tpl=`list_li`&display=`all`&filter=`hidemenu,0`]] 

      And here is another example from my own news section:
      [!Ditto? &parents=`335` &tpl=`main_news` &showInMenuOnly=`1` &sortBy=`createdon` &pagination=`0` &display=`8` &depth=`2` &hideFolders=`1` &sortDir=`DESC`!]

      You’ll find an explanation on the different parameters here.

      Good luck.  smiley
        I think, thererfor I am! But what I am, and why...?
        • 37437
        • 147 Posts
        Sylvaticus -

        Thank you very much for responding. Are there any examples of actual News-based templates out there so I can get a better sense for the way it needs to be structured? Calling the template from within the Ditto tags is pretty straightforward (i had already seen the example information you kindly linked to in your response), it is the composition of the template itself that is less clear to me. I have tried to extrapolate from the Blog template example found here: http://wiki.modxcms.com/index.php/Ditto_-_2._How_to_Display_a_List_of_Articles, but all that displays when I set a similar template in motion is - ’No Documents found’. I am obviously just not doing something right.

        Marconi
          • 36592
          • 970 Posts
          For example, below is the default template defined in assets/snippets/ditto/lang/english.inc.php
              <div class="ditto_item" id="ditto_item_[+id+]">
                  <h3 class="ditto_pageTitle"><a href="[~[+id+]~]">[+pagetitle+]</a></h3>
                  <div class="ditto_documentInfo">by <strong>[+author+]</strong> on [+date+]</div>
                  <div class="ditto_introText">[+introtext+]</div>
              </div>
          

          Replacing [+introtext+] to [+summary+] is needed when you use &extenders=`summary`.
            • 37437
            • 147 Posts
            tkfm -

            Thank you very much! I have made a lot of headway here and am now able to get a summary of a news item to display on my Home page. I do have an additional question now though:

            I am currently using the [+link+] placeholder in my Ditto call. This means (of course) that a ’read more ...’ link is available at the bottom of the news summary. Furthermore, when this link is clicked, the browser navigates away from the Home page (where the item summary is listed) and opens the page that lists the entire news item. How difficult would it be to have the news item display right on the Home page, rather than open in a new page altogether? Ideally, what I would like is to have the full News item display in place of the News summary itself? (The News summary sits between a particular set of Div tags on the Home page.)

            I am thrilled to have finally gotten the Ditto call to work. Now it is just a matter of getting some remaining behavioral and formating details down.
              • 4310
              • 2,310 Posts
              Most likely you would need to attach a Javascript function to the [+link+] in your Ditto template to load the full news page into a <div>.
              Have a look at Mootools or one of the other JS libraries, they all have that capability.
                • 37437
                • 147 Posts
                bunk58 -

                Thanks for the tip. I will look into MooTools a bit, although I am really not much of a programmer. Perhaps Ditto already provides a way to set a Div within a specific document as the Target in which a news item displays (I will look into that some more too).
                  • 4310
                  • 2,310 Posts
                  Is this the sort of thing you meant http://www.sandbox.3913.co.uk/index.php?id=9
                  I’ve done no styling but it’s two articles summarised but the whole two articles are also hidden on the page and appear when the summary title is clicked.
                    • 37437
                    • 147 Posts
                    bunk58 -

                    That is not exactly what I had in mind, but it is very elegant; I like it. My initial idea was to have the full News content completely replace the Summary content (rather than display below it). For the time being I have actually gone with a simpler approach and have the full News content display on a new page. So, i take it that you used some javascript to change the display on the full articles from hidden to show.

                    Thanks bunk58.

                    - Marconi