We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15175
    • 116 Posts
    I have created individual news-pages which all use the same template. In this template I have used

    [*pub_date:date=`%A %d %B %Y`*]


    in order to display the date.

    However, when I display these news-pages via ditto , the published date of the page with the ditto call is used instead of the individual news-pages date.

    How could I get round this?
      • 15175
      • 116 Posts
      I think I’m going to have to have another look at how I’m implementing Ditto, the templates and the placeholders.
        • 20413
        • 2,877 Posts
        1. Use Ditto Tpl’s to control what you want to show.

        Available placeholders
        Any document object or template variable in the format of [+documentobject+]
        [+url+] - URL of the item
        [+author+] - Author of the item
        http://ditto.modxcms.com/tutorials/creating-a-custom-template.html

        DATE [+date+] placeholder is missing out here! tongue
        http://ditto.modxcms.com/files/snippet-ditto-php.html#dateFormat

        Example Tpl
        [+content+]
        [+date+]

        2. Then in the Ditto snippet call: &dateFormat=`%A %d %B %Y`
          @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
          • 15175
          • 116 Posts
          Unfortunately this just doesn’t work.

          My ditto call:

          [[Ditto? &parents=`67` &display=`1` &tpl=`ditto-news-tpl` &tplPaginatePrevious=`news-previous-tpl` &tplPaginateNext=`news-next-tpl` &paginate=`1` &paginateAlwaysShowLinks=`0` &sortBy=`createdon` &sortDir=`ASC` &dateFormat=`%A %d %B %Y`]]


          As can be seen, I am using ditto-news-tpl as the template chunk for ditto. Within this template I have the following:

          <p id="date">[+date+]</p>


          All the other placeholders and formatting works.

            • 16278
            • 928 Posts
            Have you tried
            [+pub_date:date=`%A %d %B %Y`+]
            in your original version (plus, not asterisk, so as to pick up the retrieved documents’ pub_date field, not the parent’s)? It should work, regardless of what you do with [+date+].
            But [+date+] should be producing something - either the field you set in Ditto as the &dateSource (e.g. &dateSource=`pub_date`) in the format &dateFormat you request, or the createdon date if you don’t name a source.
            smiley KP
            Notes on Ditto at http://www.pogwatch.com/ditto (see section on Ditto and PHx)
              • 15175
              • 116 Posts
              Nope, nothing seems to work, thanks anyway kp25. I’ve also tired turning off PHx, and all the different page caching options.

              This is what I’ve got:

              Individual news pages in a container folder with the id 67.

              I’ve stripped down my ditto call so the default tpl is used:

              [[Ditto? &parents=`67` &display=`1` ]]


              All i get back is this :

              Title
              
              by Default admin account on 


              The date is ignored even from the default tpl.





                • 16278
                • 928 Posts
                Hmmmmm - I’d say that sounds like something is wrong with the installation. What versions of things are you using?
                Do you get anything with &debug=`1` in your call? It should give you some idea what Ditto is actually seeing, including the template code it’s using.
                huh KP
                  • 15175
                  • 116 Posts
                  Here is the debug output:

                  http://www.panoco.co.uk/misc/ditto2.1.0_debug_doc78.html

                  The date shows up everywhere except in the retrieved data.

                  The other details:

                  MODx version: 0.9.6.3
                  ditto_version = "2.1.0"




                    • 16278
                    • 928 Posts
                    That tvdate looks a bit suspicious - have you by any chance created a template variable called "date" (and left it empty)? Ditto would prefix your variable’s name with "tv".
                    wink KP
                      • 15175
                      • 116 Posts
                      Excellent - that was it - thanks a lot KP grin

                      I had an unused TV called date that was messing things up - I just had to delete it.

                      Thanks again.