We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30497
    • 245 Posts
    Hi,

    I have banged my head against this one for some time, and the documentation I could find is inconclusive.

    So, How do I display the author and published date on a page? I can do this easily with Ditto, but on normal pages, what is the correct MODx markup to use?

    Another thing unclear to me from documentation: pub_date or publishedon ? I use pub_date in my ditto calls and everything works, but is there a "publishedon" tag in MODx (like "createdon")?
      • 9130
      • 171 Posts
      Had the same problem a few days ago and ended up using the AuthorTimestamp snippet. I tried using the built-in date tag but the result is in some kind of unix timestamp format not meant for human consumption.
        • 30497
        • 245 Posts
        Quote from: etal at Mar 18, 2009, 03:44 AM

        Had the same problem a few days ago and ended up using the AuthorTimestamp snippet. I tried using the built-in date tag but the result is in some kind of unix timestamp format not meant for human consumption.

        yes, exactly! strange output on [*date*].

        Thanks for the snippet link, big help!
          • 9130
          • 171 Posts
          It later occurred to me that this might also be solved using PHx but I haven’t tried it myself.
            • 30497
            • 245 Posts
            Quote from: etal at Mar 18, 2009, 04:30 AM

            It later occurred to me that this might also be solved using PHx but I haven’t tried it myself.

            I tried using the date string with PHx but I got weird results, like 1.1.1970 as the publication date smiley
              • 16278
              • 928 Posts
              There’s a full list of available document fields, with comments, at http://svn.modxcms.com/docs/display/MODx096/Document-Specific+Resource+Fields#Document-SpecificResourceFields-pubdate. Note that pub_date will be zero, unless you have set a date to schedule publication some time in the future. And zero will show as 1 Jan 1970.
              Generally you should find that createdon or editedon will supply the required date and time, and you can format them with PHx, which will also extract the user information from the user relevant ID:
              Created on [*createdon:date=`%d.%m.%Y %H:%M`*] by [*createdby:userinfo=`username`*]
              Edited on [*editedon:date=`%d.%m.%Y %H:%M`*] by [*editedby:userinfo=`username`*]

              There also seem to be a "publishedon" and "publishedby" fields in the database table. These are not documented in the list, but produce output as [*publishedon*], [*publishedby*].
              laugh KP