Jump to content

Some thoughts/informations on selectors


MadeMyDay
 Share

Recommended Posts

While developing my dashboard module I came across a lot of difficulties when building a configurable filter for selecting pages for the last pages widget. Some things I discovered:

  • "or" filter in native page fields didn't work. Fixed by Ryan in the last commit (Big thanks!): https://github.com/ryancramerdesign/ProcessWire/commit/70093241b2cbfe7cae79f28531c1a5df1a572169
  • It is was somehow difficult/impossible to use get('/')->find(...). This resulted in weird results where direct children were not in the results array. Should also be fixed (not tested).
  • There is an undocumented selector "has_parent" which looks for a parent up to the root. Quite handy! So "has_parent!=2" removes all admin pages (except admin itself, add id!=2 for that) from a select (thanks @Soma!).
  • The "user" which created the standard pages is not the superuser. This was the reason I doubted my results because I thought the superuser would have created everything. Me stupid.
  • The inputFieldSubmitButton module generates a button which gets doubled in the admin head section. Couldn't find the place where this happens until I found out that this is generated with Javascript. Me stupid again.
  • Important rule for selectors: First "has_parent" (if needed), second "include=all" (if needed), then the other filters. And in the end "sort" and then "limit". Not sure about this, but this works for me, so I have only one selector which seems to be correct. For example the latest pages for a specific user which are not admin pages (and no trash):
has_parent!=2,id!=2|7,include=all,created_users_id|modified_users_id=41,sort=-modified,limit=10

Looks easy, but wasn't (at least for me) ;)

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

×
×
  • Create New...