Is it possible to have getResources to sort by a template variable of the resources? I’m have ’Events’ resources that have an ’event_date’ TV. I would like to order the listing of these events by that TV rather than by publishedon or createdon etc.
I’ve tried several attempts at the call, including:
[tt][[!getResources? &parents=`20` &includeTVs=`1` &limit=`20` &sortBy=`[[+tv.event_date]]` &tpl=`events_listing_preview`]][/tt]
and
[tt][[!getResources? &parents=`20` &includeTVs=`1` &limit=`20` &sortBy=`+tv.event_date` &tpl=`events_listing_preview`]][/tt]
and
[tt][[!getResources? &parents=`20` &includeTVs=`1` &limit=`20` &sortBy=`event_date` &tpl=`events_listing_preview`]][/tt]
But none work.... If it’s not currently possible to use TV’s, could someone point me in a direction of how I can modify the getResource snippet to allow for that functionality?
Thanks in advance
-
MODX Staff
- 10,725 Posts
getResources does not currently support this, but I will look into added this feature with some other feature additions (i.e. sorting by multiple columns).
Thanks for the information! That’s unfortunate, but at least now I know I wasn’t going crazy ;-) I’ll just use the publishedon field instead for now. Looking forward to the day that those advanced sorting features make there way into the snippet!
I know this has been a while, but has there been any progress on being able to sort by template variables? I’m building a clothing shop and I need to be able to sort my pages by size, price etc...
Many thanks.
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
Is it also possible to sort the resources by a TV which is located in that resource containing the command [[getResources]]?
That would be great for my purpose...