nurkka Posted 4 hours ago Share Posted 4 hours ago Hi all, when using the following selector, ProcessWire finds all pages, not only those with the CheckboxReversed "checkbox_export" checked. $ps = pages()->find('checkbox_export!=1, sort=id, include=hidden, status<' . Page::statusTrash); foreach($ps as $p){ var_dump($p->title); } As a workaround I added the following condition: $ps = pages()->find('checkbox_export!=1, sort=id, include=hidden, status<' . Page::statusTrash); foreach($ps as $p){ if ($p->hasField('checkbox_export')) var_dump($p->title); } I wonder if there is any "native" selector technique, where you can check if a field exists on a page. Something like "has_field", but that does not exists. At least I found nothing in the docs. Does anyone know the trick, if there is any? 1 Link to comment Share on other sites More sharing options...
BitPoet Posted 1 hour ago Share Posted 1 hour ago There's no direct selector option, but you could get all templates that use the field first, then use those in the selector. Unless you use the field in repeaters or related types, fieldgroup name = template name. $tpls = $fields->get('checkbox_export')->getFieldgroups()->implode('|', 'name'); $ps = pages()->find("template=$tpls, checkbox_export!=1, sort=id, include=hidden, status<" . Page::statusTrash); 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now