We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16278
    • 928 Posts
    I’m curious to know why your snippet call is Ditto_2 rather than just Ditto?

    If you’re using the current version of Ditto, the you can specify the sort variable and order in one with &orderBy (e.g. &orderBy=`dateArticle DESC`). In older versions (and in the current version, optionally) you set them separately (&sortBy=`dateArticle` &sortDir=`DESC`)

    The date supplied to Ditto has to be in the Unix timestamp format, which represents the number of seconds since 1st January 1970. MODx stores createdon and some other dates in this format. Fortunately, you don’t have to do any complicated sums to generate the right number. Just set your TV input type to Date, and the Widget to Unixtime, and store dates in an unambiguous (and human-readable shocked) format such as "23 March 2009". The widget does the conversion using PHP’s "strtotime" function and feeds Ditto the date in the required format.

    You tell Ditto what your date source is with the &dateSource parameter, then use the placeholder [+date+] in your template. See http://ditto.modxcms.com/files/snippet-ditto-php.html for details on Ditto 2.1 parameters.

    So, adjusting for the above, your Ditto call (with other parameters left as they were) now reads:

    [!Ditto_2? &startID=`1` &summarize=`5` &total=`all` &tpl=`DittoTemplate` &paginate=`1` &paginateAlwaysShowLinks=`1` &orderBy=`dateArticle DESC` &dateSource=`dateArticle` &dateFormat=`%B %y` &extenders=`summary`&debug=`1` !] 
    

    And your template begins
    <div class="ditto_documentInfo"><strong> [+date+]</strong> </div> 
    
      • 9133
      • 17 Posts
      Thank you to all of you ! But unfortunately nothing works and it seems that I am not the only one who has this problem.

      AHHP: I modified assets\snippets\ditto\classes\ditto.class.inc.php line 915 as suggested in another post ([Tutorial] Sort by a user defined date.)

      Beautiful cat kp52: I did exactly what you proposed, but the result is: no sorting, dates appear in Unixtime on the Article, do not appear at all in the "Summary". (By the way "Ditto_2" is just a copy of Ditto, to be sure to keep the original as it is).

      bob1000: Your solution could be used if I were the only one to post the articles. Most of the articles to be posted are "old". I can expect that every "author" changes the publishing date, via the Doc Manager.

      I really wonder why all this does not work huh????
        • 3707
        • 241 Posts
        Why do you need a custom date field? Can’t you just use the "Publish Date" field, you can enter earlier published dates in there.
          • 25663 MODX Staff
          • 12,272 Posts
          If you use a custom date TV, make sure to turn on the unixtime output filter (widget), or your sorting won’t work at all.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 9133
            • 17 Posts
            Thanks bob1000 !

            I’ll probably have to to use the "Publish date" solution, although it is not the most elegant one. It was suggested by AHHP at the beginning also.

            But what should be the Ditto call ? I tried a lot of variants, but get always the Unixtime on the Summary as well as on the article.

            Thanks also rthrash ! I tried also with the unixtime widget for my custum date. It does not sort out, unfortunately.
              • 25663 MODX Staff
              • 12,272 Posts
              Are you by chance running MySQL version 5.0.51?
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 9133
                • 17 Posts
                It is MySQL 5-1
                  • 9133
                  • 17 Posts
                  Or rather Server version 5.0.68
                    • 9133
                    • 17 Posts
                    Sorry, I found also this among the information : MySQL client version: 5.0.32 . I do not know exactly to what your question refers to.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      You can have a different MySQL client than the server. What’s the server version, as I’m seeing three different responses above.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me