Reputation: 15458
I want to order my resources by menu index and have the following code:
[[!getResources? &parents=`50` &sortdir=`ASC` &sortby=`menuindex` &limit=`100` &includeTVs=`1` &processTVs=`1` &tpl=`temp` ]]
But the sortby
just isn't working.
Would anyone know what I am doing wrong?
Thanks!
Upvotes: 2
Views: 5723
Reputation: 1
I had a similar problem. solution:
[[!getResources? &parents=`50` &sortdir=`ASC` &sortby=`{"menuindex":"ASC"}` &limit=`100` &includeTVs=`1` &processTVs=`1` &tpl=`temp` ]]
.
&sortdir=`ASC` &sortby=`{"menuindex":"ASC"}`
Upvotes: 0
Reputation: 113
Maybe try to put the sort direction and sort by in the same call. Get rid of the $sortdir in your snippet call.
[[!getResources? &parents=`50` &sortby=`{menuindex:ASC}` &limit=`100` &includeTVs=`1` &processTVs=`1` &tpl=`temp` ]]
Upvotes: 1
Reputation: 831
@OptimusCrime,
The Json format is optional. It can be a string as usual:
Any Resource Field (excluding Template Variables) to sort by. Some common fields to sort on are publishedon, menuindex, pagetitle etc, but see the Resources documentation for all fields
Check your menuindex instead, probably they have the same number, (eg: 0s (zeros)) which make them can not be sorted.
Upvotes: 0
Reputation: 14863
If you read the documentation, you can see that the sortby
-field have to be encoded as a JSON-string. http://rtfm.modx.com/display/ADDON/getResources
If you want to order by menuindex, this should work:
[[!getResources? &parents=`50` &sortdir=`ASC` &sortby=`{"menuindex":"DESC"}` &limit=`100` &includeTVs=`1` &processTVs=`1` &tpl=`temp` ]]
Upvotes: 5