Jump to content

'!=' selector excludes empty fields


Recommended Posts


This selector works as expected, excluding all the story pages that have "accepted" in the external_status field, but it also excludes stories with no external_status defined (field is empty). How can I make sure those pages are included?

Link to comment
Share on other sites

depending on your PW version:

before 2.5: https://processwire.com/talk/topic/2942-or-in-pw-selectors/#entry29001

Hhm, cannot find it, but I could swear there is support for OR operators in selectors now in 2.5. Sorry, you need to search for it by yourself, maybe in the http://processwire.com/blog section. Or if someone reads this: do we have support for OR operators in PW 2.5 now? Where can we read about it?

Edited by horst
  • Like 1
Link to comment
Share on other sites

Yes we do...OR-groups

Both of these work for me (not sure if the second one is the better syntax though for this particular case):

$test = $pages->find('template=basic-page, foo=(external_status=""), foo=(external_status!=accepted), sort=title');
$test = $pages->find('template=basic-page, (external_status=""), (external_status!=accepted), sort=title');


Related new(ish) selector,  selector grouping


  • Like 6
Link to comment
Share on other sites

@kongondo I still don't understand the reason for naming groups (foo=(...)) ... is it just for readability?

I have to admit I don't like the OR syntax, it is not intuitive to me. Why not just use the single pipe like everywhere else in selectors? Or at least the double pipe.

Don't get me started with the @ for AND matches, instead of the known &&, but that's just me.

Edit: I guess the parsing for that is not too trivial an might make things slower, don't know though.

  • Like 2
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

  • Create New...