We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4513
    • 16 Posts
    hello,
    I have a problem with sorting by a template var which type is a date,
    My Ditto call is like this:
    [[Ditto? &parents=`21,27` &tpl=`showNews` &depth=`1` &sortBy=`tvmyDate`&total=`all`&summarize=`3` &paginate=`1` &display=`all`&paginateAlwaysShowLinks=`1` &tplPaginatePrevious=`previousLNEn` &&tplPaginateNext=`nextLNEn` &tplPaginatePreviousOff=`` &tplPaginateNextOff=`` &dateFormat=`%c`&debug=`1`]]


    And here is a definition of myDate (screen shot):

    I get following output from the Ditto call(e.g.):
    http://212.85.126.15/smartmedia/index.php?id=58&start=6
    and here is debug information:
    http://212.85.126.15/smartmedia/ditto2.1.0_debug_doc58.html

    I also tried with orderBy and myDate instead tvmyDate.

    Any suggestions?
    Thank You in advice
      • 27708 MODX Staff
      • 2,502 Posts
      Is that Ditto Call copied and pasted? There are some issues with no spacing and double ampersands.:

      [[Ditto? &parents=`21,27` &tpl=`showNews` &depth=`1` &sortBy=`tvmyDate`&total=`all`&summarize=`3` &paginate=`1` &display=`all`&paginateAlwaysShowLinks=`1` &tplPaginatePrevious=`previousLNEn` &&tplPaginateNext=`nextLNEn` &tplPaginatePreviousOff=`` &tplPaginateNextOff=`` &dateFormat=`%c`&debug=`1`]]


      should be:

      [[Ditto? &parents=`21,27` &tpl=`showNews` &depth=`1` &sortBy=`tvmyDate` &total=`all` &summarize=`3` &paginate=`1` &display=`all` &paginateAlwaysShowLinks=`1` &tplPaginatePrevious=`previousLNEn` &tplPaginateNext=`nextLNEn` &tplPaginatePreviousOff=`` &tplPaginateNextOff=`` &dateFormat=`%c` &debug=`1`]]


      See if that works. There should be a space between the previous parameter and the next. In addition you had &&tplPaginateNext=`nextLNEn` vs &tplPaginateNext=`nextLNEn`. Hope this helps.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 4513
        • 16 Posts
        Thank you for your reply,
        but it doesnt work.
        It could be a problem linked with that myDate is a Date Formatter and not Unixtime.
        Maybe it must be a type Unixtime? and next apply some formatting for the output.
          • 4310
          • 2,310 Posts
          Maybe it must be a type Unixtime? and next apply some formatting for the output.
          That’s what I usually do.
            • 16278
            • 928 Posts
            Yes, the date must use the Unixtime widget for Ditto to be able to do anything with it. You can sort with &orderBy=`myDate ASC` or &orderBy=`myDate DESC` (no need for "tv" prefix in Ditto 2.1), and hook up to a [+date+] placeholder in your template chunk using &dateSource=`myDate` and &dateFormat=`%d %m %Y etc.` in the Ditto call. Alternatively, use PHx output formatting in your template chunk, [+myDate:date=`%d %m %Y etc.`+].
            smiley KP
            More on Ditto at http://www.pogwatch.com/ditto.html
              • 4513
              • 16 Posts
              Thanks a lot for your posting.
              But I’m wondering why it should be a type Unixtime and not Data Formatter. Though it should be allowed to use Data Formatter when I want to sort. In my opinion this is a kind of bug;) But I can be wrong.