We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12844
    • 59 Posts
    I’m creating a basic news section for a site, and for the way I’m trying to do it I need to do this on the template for the news item "read more" page:

    [!Ditto? &parents=`(id of current news item page)` &tpl=`newsitem` &display=`1` !]


    What should I replace (id of current news item page) with please?
      • 16278
      • 928 Posts
      If you simply don’t set the &parents parameter, the current page will be used. So it reads
      [!Ditto? &tpl=`newsitem` &display=`1` !]

      wink KP
        • 20413
        • 2,877 Posts
        Yes or use &parents=`[*id*]` where [*id*] output docID for current document.
          @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
          • 12844
          • 59 Posts
          Thanks for the replies.

          I had tried it without the &parents before, and I get "No documents found". I’ve since realised that this is because Ditto is looking for more documents inside the current document to aggregate, which works fine for my main news page but as this is the "read more" page, I want it to display only the title, date and content from this page itself.

          Hope that makes sense.
            • 16278
            • 928 Posts
            If what you want to display when you click the "read more" link is the full document that’s listed by Ditto on the page containing the link, you don’t need to use Ditto on it at all - it’s just an ordinary page. You can probably make your "newsitem" chunk into a full document template to set up the pages for individual items. laugh KP
              • 12844
              • 59 Posts
              This was indeed how I started off for the actual news item pages - without Ditto, using template tags. But for the life of me I couldn’t find out if there is a template tag for the published date, which I want to be displayed.

              I expect there’s an easy way of displaying the published date which I’m unaware of.
                • 16278
                • 928 Posts
                There’s a list of "document-specific resource fields" (including several dates) on the new MODx site at http://svn.modxcms.com/docs/display/MODx096/Document-Specific+Resource+Fields.

                A few points:

                • You insert the field in the current document using [*fieldname*]
                • The time and date fields are Unix timestamps, and need to be converted one way or another to human-readable format. That’s what Ditto does to create the [+date+] placeholder when you use the &dateSource and &dateFormat parameters.

                • To translate a date in an ordinary page outside of Ditto you can either
                  [list][li]install the PHx plugin and use its "date" modifier e.g. [*createdon:date=`%d %b %Y`*] or
                • make a little snippet to use the PHP strftime() function. See http://modxcms.com/forums/index.php/topic,36264.msg218990.html#msg218990

                • Or you could create your own template variable as a Date type and use the Date Formatter widget to control the look of its output. Within reason, you can use a Text type and type the date in instead of using a date picker, and still use the Date Formatter widget. A wide range of formats (avoiding the ambiguous day/numerical month/year) can be converted to a regular format this way.
                [/li]
                [li]Whether the pub_date field has a non-zero value depends on how you are creating your pages. It’s really the "when to publish" date rather than the "published on" date. The createdon and editedon dates are updated automatically, which may they suit you better. I think NewsPublisher will set pub_date to the same as the createdon date if you don’t fill in the "publish on" field for delayed publication. You can set pub_date manually if in the Page Settings tab you’re creating documents in the MODx manager.[/li]
                [/list]
                The choice is yours (maybe that’s the problem huh)
                smiley KP
                  • 12844
                  • 59 Posts
                  Thanks for the very helpful reply, kp52. I used the third solution and your snippet. smiley