Jump to content

[SOLVED] Selector not working as expected when referencing a Page field


rastographics
 Share

Recommended Posts

This is my selector:

pages()->find("template=disc_order, task.task_status=finished, order_status=pending, sort=created, check_access=0, limit=1);

The "task" field is a page reference. The "task_status" field is a Select field.

This selector works as expected when I use it on a normal template page. 

However, when I use this same exact selector in a different file (my_api.php) the selector no longer returns any results, UNLESS I REMOVE:

task.task_status=finished

If I remove "task.task_status=finished" and add "task.id=34234" instead, it will return results.

Or if I run this same selector in my template, it works.

Scratching my head here, this is really weird...

Edited by kongondo
Moderator note: marked topic as solved.
Link to comment
Share on other sites

@Zekathanks, yes I did try that. It does not work. I also tried the number value that corresponds with that option.

I have other queries in my api that have selectors that just use the task_status field, but not as a sub-selector on a page reference field. So just 'task_status=finished'. 
Those work fine. Just getting the 'disc_order' template and using 'task.task_status=finished' is what does not work.

What is baffling is my query works in the page finder. It also works when I put it in a template page. My api.php page has many other queries using other selectors, and none of them behave different than expected. (None of them are trying to select based on a property of a Page field, however)

 

Link to comment
Share on other sites

@psyThat's exactly what I was looking for...a way to make sure the entities are eager loaded. Just didn't know it was a thing and what it was called :)

Well, turns out that when I tried to use "join"...it didn't work because my processwire wasn't on a recent enough version.

So when I upgraded to latest master version...it works! And furthermore...it works WITHOUT using the join feature as well.

Just needed to upgrade...must have been a bug somewhere that got fixed in the past year.

 

Thank you everyone!

  • Like 2
Link to comment
Share on other sites

  • kongondo changed the title to [SOLVED] Selector not working as expected when referencing a Page field

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   0 members

    • No registered users viewing this page.
×
×
  • Create New...