Jump to content

Checkbox Reversed – select all pages where a checkbox is checked


nurkka
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   1 member

×
×
  • Create New...