How to sort Modx Ditto documents ID when using &documents?

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 "" in assets/snippets/ditto/extenders/


if (!function_exists('customsort'))
function customsort($a, $b)

if ($pos_a == $pos_b)
return 0;
return ($pos_a < $pos_b)?-1:1;

$orderBy["custom"][] = array ("id", "customsort");
$ditto->advSort = true;


Then documents are in the order you needed.

Yandex.RTB R-A-454402-1

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment Notes of web-specialist
Since 2009