I found very nice extender for Ditto Modx.
When using snippet Ditto with custom page Ids, you have strange sorting - I haven't even understood which one.
For sorting documents as you write in &documents=[x, xx, xxx, xxxx]
you shoul use the ditto-extender below.
Write Ditto callout this way:
[[Ditto? &tpl=razdel200
&documents=[1,4,3,5,212,23,44]
&extenders=customsort
]]
You should save file "customsort.extender.inc.php" in assets/snippets/ditto/extenders/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?php if (!function_exists('customsort')) { function customsort($a, $b) { $pos_a=array_search($a['id'],$GLOBALS['documents']); $pos_b=array_search($b['id'],$GLOBALS['documents']); if ($pos_a == $pos_b) { return 0; } return ($pos_a < $pos_b)?-1:1; } } $GLOBALS['documents']=explode(',',$documents); $orderBy["custom"][] = array ("id", "customsort"); $ditto->advSort = true; ?> |
Then documents are in the order you needed.