modxmodx-revolutionmodx-getresources

getResources: Way to order Resources by &resources property?


I want to order resources in the order I have them in the $resources property eg:

2,6,3,8

But this seems to defualt to menu index.

Does anyone know a way to achieve this?

My getResources call:

           [[!getResources?  
                &tpl=`featuredtpl` 
                &resources=`2,6,3,8`
                &limit=`4`  
                &includeTVs=`1`  
                &processTVs=`1`
                &includeContent=`1`   
                &depth=`0`  
            ]]

Solution

  • You can use it like this:

    &sortby=`FIELD(modResource.id, 4,7,2,5,1 )`
    

    So your snippet call will be like:

            [[!getResources?  
                &tpl=`featuredtpl` 
                &resources=`2,6,3,8`
                &sortby=`FIELD(modResource.id,2,6,3,8)`
                &limit=`4`  
                &includeTVs=`1`  
                &processTVs=`1`
                &includeContent=`1`   
                &depth=`0`  
            ]]