We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41970
    • 79 Posts
    I have a News page with articles, built with MIGX, and I would like for each item to show the created date. If I use [[+createdon....]], it only shows the created date of the resource, not the MIGX item itself.
    Is there a way to get the MIGX item created date?
    • I'm pretty sure there isn't; you'll probably need to have a date/time picker as one of the TV fields.

      Come to think of it, a date-type "helper" TV as an inputTV field with the date-type TV's default set to 'now' should do the trick. http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types

      And after a little experimentation, I've discovered you can use an inputTVtype of 'date', and set its default to be 'now':
      {"field":"date","caption":"Time","inputTVtype":"date","default":"now"},


      You'll need to use a modifier for the [[+date]] placeholder in your tpl to get the date displayed the way you want it. http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29#InputandOutputFilters%28OutputModifiers%29-Stringoutputmodifiers [ed. note: sottwell last edited this post 10 years, 9 months ago.]
        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
        • 41970
        • 79 Posts
        Thank you for your input! I tried it out, but even if I pick a different date from the date picker now, the output on the front end is always the current date. If I remove the "now" default, it doesn't show anything, even though I pick a date. In the MIGX grid it shows the correct date, the one I picked, but on the front end, the incorrect date, which is the current date.
        What could there be wrong?

        EDIT: I solved it, it works now, thank you!!! [ed. note: bblinda74 last edited this post 10 years, 9 months ago.]
        • What does your getImageList tpl look like?
            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
            • 41970
            • 79 Posts
            Ok now I got it to work but the date format I don't like. I would like to use `Full Day Name, Day, Month, Year`, but when I use `%A, %B %e, %Y` all I get is Wednesday, December 31, 1969!! Even though I pick a date in the MIGX, I still get the weird 1969 date!

            My call is: [[!getImageList? &tvname=`news` &tpl=`newsItems`]] , and my newsItems tpl chunk looks like this:

            <div class="newscontainer">
            
            <div class="newsimage">
              <a href="[[+newsImage:phpthumbof=`w=600&h=450&zc=1`]]" class="colorbox" title="[[+newsHeadline]]"><img src="  
              [[+newsImage:phpthumbof=`w=234&h=138&zc=1`]]" alt="[[+newsHeadline]]" /></a>
            </div>
            
            <div class="newstext">
              <p class="curDate">[[+newsDate:date=`%A, %B %e, %Y`]]</p>
              <h3>[[+newsHeadline]]</h3>
              <p>[[+newsText]]</p>
            </div>
            </div><!-- End Newscontainer -->
            <hr>
            


            Do you know what there could be wrong with the time formatting now?

            EDIT: Ok, I think my brain must be overheated or something, because I solved it myself now. I have to use [[+newsDate:strtotime:date=`%A, %B %e, %Y`]], then it outputs the correct date.
            Still not sure where the weird 1969 date stamp comes from, but ok wink
            • That's the beginning of the UNIX "epoch", sort of like the year 0. If the date or time functions don't get a good timestamp to work from, they default to that. The timestamp is the count of seconds from that beginning.
                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
                • 41970
                • 79 Posts
                Interesting information wink
                Is it possible to sort the output of my news articles by date, so that the latest is always first, not the other way round, like it is now? I tried {"sortby":"newsDate","sortdir":"DESC"}, but it doesn't have any effect on the output.

                EDIT: Ok I'll get a bad reputation in here, if I keep asking questions and then answering them myself shortly after. So sorry about this, this is the solution:
                &sort=`[{"sortby":"newsDate","sortdir":"DESC","sortmode":"datetime"}]` [ed. note: bblinda74 last edited this post 10 years, 9 months ago.]
                • That's OK, any and all documentation is good. I've never run across "sortmode" before.
                    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
                    • 41970
                    • 79 Posts
                    Well, I am fairly new to building websites, used modx before but quite a while ago, and now I am slipping more and more from designing only into building websites too. I enjoy using modx very much, I must say, just sometimes I get stuck and I am glad there are people like you here in this forum smiley Thank you again!
                      • 33238
                      • 388 Posts
                      Quote from: sottwell at Jul 02, 2013, 06:17 AM
                      I'm pretty sure there isn't; you'll probably need to have a date/time picker as one of the TV fields.

                      Come to think of it, a date-type "helper" TV as an inputTV field with the date-type TV's default set to 'now' should do the trick. http://rtfm.modx.com/display/revolution20/Template+Variable+Input+Types

                      And after a little experimentation, I've discovered you can use an inputTVtype of 'date', and set its default to be 'now':
                      {"field":"date","caption":"Time","inputTVtype":"date","default":"now"},


                      You'll need to use a modifier for the [[+date]] placeholder in your tpl to get the date displayed the way you want it. http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters+%28Output+Modifiers%29#InputandOutputFilters%28OutputModifiers%29-Stringoutputmodifiers

                      Excellent sottwell, Thank you very much! smiley
                        --
                        ysanmiguel.com