We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16484
    • 4 Posts
    I have a folder which has a whole bunch of resources beneath it which i am using to handle news article display. Which is working fine.

    I am using the following chunk to display the actual headlines of the news:
    <li><b>[+title+]</b><br /><span style="font-style: italic;">[+date+]</span><p style="line-height: 1.25;">[+longtitle+]</p></li>


    Which shows the date that the article was actually created on (December 15 2009 for example). I have set it’s publish date as October 18 2009. What I would like to do is instead of showing the date as it appears now (Dec 15) is to show the date that the article was/will be published on instead.

    I’ve read the wiki and forums and couldn’t come across a solution I could get working. This is my first time using Modx and so far I love it, but this is the only thing causing me an issue.

    Could anyone help me figure this out? I may have posted this in the wrong place it seems :/
      • 7231
      • 4,205 Posts
      If you are using Ditto to generate the news list you need to set the &dateSource parameter to &dateSource=`pub_date` so that the [+date+] placeholder reflects the date set on the Published field in the manager.

      However, if you are wanting the date to show outside of a Ditto template chunk you will need to use a snippet to format the date from the default unix time stamp. One that I have used is dateTime or AuthorTimestamp.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 16484
        • 4 Posts
        I tried the above but no luck.

        I used AuthorTime snippet with the following:
        [[AuthorTime? &dateFormat=`%d %B %Y - %H:%M` &usedDate=`pub_date`]]

        And it returns:
        By Default admin account on 01 January 1970 - 10:00

        However if I change it to:
        [[AuthorTime? &dateFormat=`%d %B %Y - %H:%M` &usedDate=`publishedon`]]


        It returns:
        By Default admin account on 15 December 2009 - 10:32

        Which is a step closer but the date is entirely not what I am looking for.

        This is an overhaul of an existing site and as a result I need to back date several items. So far not having much luck. I have managed to narrow the problem down to the fact that then $docInfo array does not the pub_date value from the database inside of it, it instead just a zero in place of what it is from the DB. Which suggests that $modx->getDocument() is not working correctly. any ideas?
          • 7231
          • 4,205 Posts
          Is the date set in the Published field in the manager for the specified document? the pub_date will reflect the date that is set with the widget and the publishedon will reflect the date that the document was published regardless of the date set in the manager.

            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 16484
            • 4 Posts
            Yep it has a date set. The pub_date field is set correctly in the database and in the manager itself. However when tring to query the pub_date through a snippet it is always returning zero for the pub_date field.

            I made a few edits to my last reply just after you responded.
              • 3749
              • 24,544 Posts
              That’s very strange. The getDocument() function gets all fields by default and the snippet simply uses the field sent in the argument.

              Be sure &usedDate has two d’s in the middle and the placeholder is [+Date+], not [+date+].
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 16484
                • 4 Posts
                Yep tried that. But as I said if i do a print_r on the getDocument function (inside the snippet so it is dumped out on the page itself) the pub_date field is set to zero. However according to the database it has a pub_date of ’1254976380’. As far as I can tell the snippet works perfectly fine, the problem is with the getDocument somewhere (This is on a fresh install of Evolution 1.0.2).

                But I have figured out why it is set to zero, it is grabbing the info of the current open page not the sub resources I am trying to open. Doh!

                Problem solved now laugh
                  • 3749
                  • 24,544 Posts
                  Doh here too. I should have thought of that. tongue
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting