I am new to modx revolution and I have pretty weird task. I have this:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=`127,106`
&resources=`-831,-243`
&depth=`2`
&limit=`21`
&pageVarKey=`page`
&includeTVs=`1`
&includeContent=`1`
&tpl=`pageAllDoctors`
&hideContainers=`true`
&sortby=`FIELD(modResource.id, 456,331,390,491,2756,505,634,699,941,1044,1377,1436,1449,1678,1722,1711,1828,2007,2094,2184,2324,2487,2527)`
&where=`[{"introtext:LIKE":"%[[!searchFieldClinic? &field=`spec`]]%", "AND:introtext:NOT LIKE":"%заведу%", "AND:template:=":104}]`]]
In the sortby I have a list of resources that are to be shown first and then the remaining resources. The only thing is that I need them not only to be first but also displayed random and not mix up with other resources that come after them.
Is there any way to do that?
Thanks in advance.
solved the issue with snippets:
&sortby=`FIELD(modResource.id, [[!shuffleVals?&vals=`456,331,390,491,2756,505,634,699,941,1044,1377,1436,1449,1678,1722,1711,1828,2007,2094,2184,2324,2487,2527`]])`
Snippet
<?php
/**
* @package shuffleVals
*/
$output = '';
$properties =& $scriptProperties;
$properties['vals'] = explode(',', $properties['vals']);
shuffle($properties['vals']);
$properties['vals'] = implode(',', $properties['vals']);
return $properties['vals'];