Ajax Driven Dropdown Lists for ProcessWire made easy

First Column Custom PHP Code

This setting overrides the selector specified in First Column Selector. Here you can specify valid PHP code to return data for the first column/dropdown. The statement must only return a WireArray derived object such as group of templates or a PageArray.

The statement entered here has access to the ProcessWire API variables $page, $pages, $templates and $users. Since the statement will be evaluated on page load, you need to be very careful about what the code actually does.

Below are some example custom PHP code.

return $page->children("limit=10");

return $templates->find("tags=some-tag");

return $users->find("");

A more complex example (please note this is pseudo code!)

$myPages = $pages->find('template=some-template, limit=50');
$pA = new PageArray();
foreach($myPages as $p) {
    if($p->someField != 'some condition') continue;
    else $pA->add($p);
}
return $pA;