Question

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!

Was it helpful?

Solution

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` ]]

OTHER TIPS

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` ]]

@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.

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"}`
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top