rastographics Posted October 13, 2021 Share Posted October 13, 2021 (edited) 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 October 14, 2021 by kongondo Moderator note: marked topic as solved. Link to comment Share on other sites More sharing options...
Zeka Posted October 13, 2021 Share Posted October 13, 2021 Hi @rastographics "task_status" is select options field? Have you try to 'task.task_status.title=finished' ? 1 Link to comment Share on other sites More sharing options...
rastographics Posted October 13, 2021 Author Share Posted October 13, 2021 @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 More sharing options...
psy Posted October 13, 2021 Share Posted October 13, 2021 Just a thought... maybe change it to findJoin and add the task.tast_status field to ensure it's included in the query? https://processwire.com/api/ref/pages/find-join/ 2 Link to comment Share on other sites More sharing options...
rastographics Posted October 13, 2021 Author Share Posted October 13, 2021 @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! 2 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