Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature parity for the use of selectors in WireArray vs PageFinder #2009

Open
Toutouwai opened this issue Aug 31, 2016 · 6 comments
Open

Feature parity for the use of selectors in WireArray vs PageFinder #2009

Toutouwai opened this issue Aug 31, 2016 · 6 comments

Comments

@Toutouwai
Copy link

It would be nice if selectors worked the same across both WireArray/PageArray and PageFinder.

For a $pages->find() selector we can use relative time strings and friendly names for page statuses (locked, hidden, etc) but not for a PageArray selector. It would be great not to have to keep these differences in mind and just use selectors consistently across the whole API wherever possible.

@ryancramerdesign
Copy link
Owner

WireArray is applicable to all object types in ProcessWire, whereas PageFinder is exclusive to finding pages from a database. While they might seem similar in usage on the surface, they are fundamentally different. For instance, PageFinder has access to all pages in the site, whereas a WireArray (or PageArray) has only access to a limited set present in the object. PageFinder can make use of joins and various other database features, whereas a WireArray just has a flat group of items. So it won't ever be possible to say that selector usage can be identical between PageFinder and a WireArray because the context is so different. However, it may be feasible to support the two specific examples you mentioned in PageArray (time strings and page status names). Though as a matter of efficiency, this kind of filtering should really be done at at the PageFinder (database) level. When it comes to PageArray objects, having to use in-memory find/filter is often a sign that something was loaded that didn't need to be, and a place where the find should probably be modified to use PageFinder.

@LostKobrakai
Copy link

When it comes to PageArray objects, having to use in-memory find/filter is often a sign that something was loaded that didn't need to be, and a place where the find should probably be modified to use PageFinder.

That's basically every page field until the fieldtype does support pagination. These simply come preloaded without a chance to optimize the resultset beforehand.

@Toutouwai
Copy link
Author

Toutouwai commented Sep 1, 2016

Yes, it's Page fields I'm thinking of mostly.

There was an topic in the forum recently where someone was using a Page field to store items for a navigation menu, but didn't want pages with 'hidden' status to appear. Not being able to use "status!=hidden" in a selector and having to deal with bitwise values to filter the Page field is not so user-friendly.

@ivangretsky
Copy link

Robin's post opened my eyes after a few hours of not understanding, why today is not a thing in filter(). Implementing this for consistency would be pretty good. But at least some more clear docs could help.

@teppokoivula
Copy link

teppokoivula commented May 23, 2020

why today is not a thing in filter()

Stumbled into this one just yesterday, and it actually took a while to see why my query wasn't working. Even though I should be quite aware of these differences by now, it just doesn't feel intuitive, and I keep making the same mistake.

Still not a major issue as long as you're aware of it, but it's not exactly great either that one has to know/remember such quirks. +1 for implementing support for keywords such as "today" and the status names for both database and in-memory selectors :)

@Notanotherdotcom
Copy link

+1 for "today" - ran into this myself last night for the first time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants