We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30516
    • 5 Posts
    ..just saw your reply after I finished editing!

    I did do everything that was in the tutorial at http://ditto.modxcms.com/tutorials/sort-by-a-date-tv.html - my appended call is:

    [[Ditto? &startID=`4` &summarize=`4` &total=`20` &tpl=`event` &sortBy=`event_date` &dateSource=`event_date` &dateFormat=`%c` &sortDir=`DESC` &paginate=`1` &alwaysshow=`1`]]
    Showing [+start+] to [+stop+] of [+total+] events

    (My tv name specified is event_date)

    I understand about the bug, thanks v. much - but is the call itself correct?
    • That should do the job, yes.
        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
        • 30516
        • 5 Posts
        ...it doesn’t work, so it must be the MySQL bug then. I checked with my host (1&1) and they’re not offering MySQL 6 (which has bug fixed) yet. Thanks for all that bug info. so I could find that out!

        Is there any other way I can get around this instead? I know from your bug link it’s the groupby clause, but of course I’m not manually coding the groupby, I take it it’s generated by the Ditto call? Someone on that bug thread suggested "...removing the GROUP BY clause. Using GROUP BY on a
        unique index (a Primary Key, of course, is a unique index) is pointless as each row will by definition be its own group."

        EDIT: Just want to be sure you saw my earlier edit, as I was editing while you were replying - you’d said
        "The query is trying to sort by sc.event_date, but event_date is not in the sc (site_content) table. You need to specify the name of the tv to sort by in the Ditto call"

        ..I did have it in the call, but did I also need to add it to the site_content table?

        cheers,
        Tracy
        • Make sure you’ve got the latest version of Ditto installed.

          I believe some people have gone through the ditto.class.inc.php file and removed the GROUP BY clause; around line
          912
          		$sql = "SELECT DISTINCT $fields FROM $tblsc sc
          		LEFT JOIN $tbldg dg on dg.document = sc.id
          		WHERE sc.id IN (" . join($ids, ",") . ") $published AND sc.deleted=$deleted $where
          		".($public ? 'AND ('.$access.')' : '')." GROUP BY sc.id" .
          		($sort ? " ORDER BY $sort" : "") . " $limit ";
          
            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
            • 30516
            • 5 Posts
            Thanks Susan - researched Ditto upgrade there and think I need to upgrade to MODx 0.9.6. Not sure what risks are of data loss or whatever, so need to look into that first, then follow upgrade instructions for Ditto. Thanks a mill for all your help today, much appreciated!

            Tracy
              • 10290
              • 19 Posts
              This is how I solve it.

              edditing assets\snippets\ditto\classes\ditto.class.inc.php line 915

              $sql = "SELECT DISTINCT $fields FROM $tblsc sc
              LEFT JOIN $tbldg dg on dg.document = sc.id
              WHERE sc.id IN (" . join($ids, ",") . ") $published AND sc.deleted=$deleted $where
              ".($public ? ’AND (’.$access.’)’ : ’’)." GROUP BY ".($sort ? " $sort " : " sc.id ") .
              ($sort ? " ORDER BY $sort" : ""). " $limit ";

              the bold part was : ".($public ? ’AND (’.$access.’)’ : ’’)." GROUP BY sc.id" . --->So always was grouping by id
                • 33226
                • 14 Posts
                Quote from: Mark at Aug 08, 2006, 12:46 AM

                Then, just append &sortBy=`tvnameofyourtemplatevariable` to your Ditto call and you are done!

                tnx for tip!!!
                i’ve tried &orderBy=`[+nameofyourtemplatevariable+] DESC` and &orderBy=`[*nameofyourtemplatevariable*] DESC` but vain (((
                with &orderBy=`tvnameofyourtemplatevariable DESC` works good!
                  Optimizator Field