<![CDATA[ [Tutorial] Sort by a user defined date - My Forums]]> https://forums.modx.com/thread/?thread=41095 <![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238216 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!]]>
yoyurec Jul 22, 2010, 04:43 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238216
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238215 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]]>
funkafize Sep 24, 2008, 09:18 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238215
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238214
Tracy]]>
TracyCoach Aug 05, 2008, 10:00 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238214
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238213
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 ";
]]>
sottwell Aug 05, 2008, 09:47 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238213
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238212
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
]]>
TracyCoach Aug 05, 2008, 09:30 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238212
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238211 sottwell Aug 05, 2008, 09:22 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238211 <![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238210
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?]]>
TracyCoach Aug 05, 2008, 09:04 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=3#dis-post-238210
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238209 http://bugs.mysql.com/bug.php?id=32202

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, as explained in the tutorial.

&sortBy=`event_date` &dateSource=`event_date`

But there’s no guarantees, because of the MySQL bug.]]>
sottwell Aug 05, 2008, 08:47 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238209
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238208
"TVs go in their own tables in the database; they aren’t part of the site_content table" - sorry for extra explanation required - I’m new to MODx/MySQL; what’s the significance of this? I found the tv table in mySQL/phpAdmin - do I need to add the tv to the site_content table as well?

"Your sorting problem is most likely the result of a bug in the version of MySQL you are using" - again, this is probably a stupid question, but what description should I use for the bug then, when querying the MySQL bugs documentation? Don’t understand the problem enough to ask them!

All I need is some way to order them manually, whether that’s by manipulating publishing dates or whatever. I just don’t have any control over it at the minute.

Thanks very much for your time & help,
Tracy

]]>
TracyCoach Aug 05, 2008, 08:41 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238208
<![CDATA[Re: [Tutorial] Sort by a user defined date]]> https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238207
Your sorting problem is most likely the result of a bug in the version of MySQL you are using.]]>
sottwell Aug 05, 2008, 05:05 AM https://forums.modx.com/thread/41095/tutorial-sort-by-a-user-defined-date?page=2#dis-post-238207