Has something changed since the last post on this thread, abdowling’s of 22-Oct-2009? I am not able to duplicate success in using Ditto to order by a user-supplied date in a template variable.
I am using MODx 1.0.3 with no modifications to its Elements as supplied.
No problem ordering using the createdon document variable. Also, no problem defining the template variable and connecting it to the document instances: I can Preview each document to observe both createdon and TV values as unixtime long integers.
When I use this Ditto call
[!Ditto?
&debug=`0`
&parents=`[*id*]`
&display=`4`
&start=`1`
&showPublishedOnly=`0`
&orderBy=`myDate DESC`
&dateSource=`myDate`
&dateFormat=`%c`
&tpl=`departmentMainTpl`
&paginate=`1`
&paginateAlwaysShowLinks=`0`
!]
I get this error
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
PHP error debug
Error: strftime() expects parameter 2 to be long, array given
Error type/ Nr.: Warning - 2
File: /home1/gopgroto/public_html/assets/snippets/ditto/classes/ditto.class.inc.php
Line: 294
Line 294 source: $placeholders['date'] = strftime($dateFormat,$timestamp);
If I remove the &dateSource parameter, the page renders without error, but of course the intended document ordering does not happen.
Please advise if I’ve missed something, if using Ditto with a user-supplied date is done differently now, or if this is a bug. If the latter, is there a workaround?
BTW, my end goal is the same as abdowling and a few others have stated: To order on a user-supplied date, but to revert to some reasonable alternative, such as createdon or publishedon, when the user neglects to supply a date. This would allow the user to construct a decent list of future events, then put it into calendar order with a little extra work if necessary. That’s the behavior we’re trying to achieve.
For now, I’d settle for just ordering on myDate successfully.
Thanks in advance for ideas.