Modx ditto call and checkboxes

808 views Asked by At

This is my current ditto call and it works when only west is selected in the template variables (The template variable is a checkbox). I need to get this to work when multiple checkboxes are selected.

[[Ditto? &parents=`5` &depth=`1` &tpl=`map_person` &orderBy=`lastname ASC` &filter=`district,West`]]
1

There are 1 answers

0
BennyLava On

The &filter should use field,criteria,mode so if it should only work on those who have West checked you should write this:

&filter=`West,2,1|East,1,1|South,1,1|North,1,1`

So it sais: Select a document that West is checked and East isnt checked and South isnt checked and North isnt checked.

You could also create a snippet that does this and goes through the children of parent=5 and echoes out a commaseparated list with all the children IDs and put them in a &documents parameter. Something like this:

[[Ditto? &documents=`[!FindExclusive? &district=`West` &parentid=`5`!]`]]

In the Snippet-code you could write something like this (only pseudo-code under here):

$children = get all children from $parentid;
$documents = new Array();
foreach $children['id']{
    Get the checkboxes from this child
    Check if only the $district checkbox is checked
    if it is true then fill inn the id in $documents-array
}
echo implode(',',$documents);

This will generate a commaseparated list of documents that only has West checked. And you could use the same snippet for East, North and South.