We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22164
    • 50 Posts
    I want to show the date of creation and the writer name within a blog article

    If I use the following call I get ok results, but only for page with id 9

    [[Ditto? &dateSource=`createdon` &dateFormat=`%b %d %Y %I.%M %p` &documents=`9`]]

    Here is my question, How should I write this call so it grabs the current documents ID number automatically.

    I tried
    [[Ditto? &dateSource=`createdon` &dateFormat=`%b %d %Y %I.%M %p` &documents=`[+id+]`]] which does not work.

    Any ideas?

    thanks
      Happy to have left Back Pain | Sciatica behind.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      [*id*] will produce the ID of the document the Ditto snippet call is on.

      [+id+] will produce the ID of the document that Ditto is processing; this will not be available in the snippet call since the snippet hasn’t been run to set the placeholder yet. These placeholders are for use in the view tpl used for each item on the list.

      Why would you use Ditto to display only the data for one document, and the current one at that? There are any number of ways to display information from the current document without the overhead of a Ditto call. All the fields can be displayed with [*fieldname*] tags; or with a single simple snippet to display author and formatted dates.

      http://modxcms.com/extras/package/25
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22164
        • 50 Posts
        Thanks Susan,

        Good question why use Ditto, cause I knew no other way.

        Thanks for pointing me to the snipper, downloaded that, but I can not get that to work.

        You say it is possibel to show fields.

        Maybe you could give me an example of what to add to the content of an article to show the date of creation and the author?

        Thanks

        Oliver
          Happy to have left Back Pain | Sciatica behind.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          If you remove the <?php tag in the first line (make sure to leave the opening /* comment tag intact) the snippet does exactly what you want to do.
          /*
           * Simple snippet to return Author and time a document was created.
           * Original code borrowed from MetaTag snippet by Miels, converted to MODX
           * by Shane Briggs. 
           * AuthorTime snippet v1.2 (May 2006)   by OncleBen31 (based on the original version by Jason Tyler)
          .
          .
          .
          
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org