Search code examples
modxmodx-revolutiongetresource

ModX Revo: getResources not sorting by menu index


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!


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