Jump to content

2.5 selectors


martind
 Share

Recommended Posts

hi,

in the 2.5 changelog there are some words about the new selector-features:

  • Add several PageFinder optimizations and add support for @field.subfield grouping in selectors (database selectors only at present). This allows you to specify the same field twice in a selector and specify that it must match the same exact page reference. For instance, categories.active=1, categories.featured=1 will match pages that at least one one category that's active=1 and at least one category that's featured=1. Whereas, @categories.active=1, @categories.featured=1 will match pages that have at least one category that is BOTH featured AND active.
  • Update to support subselectors in selector strings. These can be used on the 'id' property of any field that maps to a page. It can also be used on the 'parent' property. Subselectors are specified between [square brackets]. Example: $pages->find("template=product, categories.id=[title%=electronics, active=1, include=hidden], include=all");

... what means "(database selectors only at present)"?

And for the second point, shouldn`t somethin like this work ...

$pages->find("template=address_abo, adrdb_multi.id=[adrdb_location.value=stp, anzahl>0]")

// or both together
$pages->find("template=address_abo, adrdb_multi.id=[@adrdb_location.value=stp, @anzahl>0]")


// ok, had to read "can be used on the 'id' property of any field that maps to a page".
// maybe this?
$pages->find("template=address_abo, (@adrdb_multi.adrdb_location.id=[value=stp], @adrdb_multi.anzahl>0)")

...trying here to query a reapeater "adrdb_multi" which contains a page-field "adrdb_location" and a textinput "anzahl" which both should be true.

thanks, martin.

Link to comment
Share on other sites

... what means "(database selectors only at present)"?

https://processwire.com/talk/topic/5083-possible-bug-page-fieldtype-with-custom-selector-to-find-selectable-pages-returns-error-while-saving-page/?p=50177

Martin, for your selector you are mixing the either-or selecting and the @ selecting, when you probably just want to use the latter. Also I don't really understand the [value=stp] part of it?

Your selector "template=address_abo, (@adrdb_multi.adrdb_location.id=[value=stp], @adrdb_multi.anzahl>0)" actually say:

  • Find all pages with template address_abo (so it finds all address_abo pages, no matter what)

    OR

  • all pages that has adrdb_multi.adrdb_location.id=[value=stp] AND adrdb_multi_anzahl>0 on same adrdb_multi page.

What you are probably looking for is something like this: template=address_abo, @adrdb_multi.adrdb_location=[value=stp], @adrdb_multi.anzahl>0

Link to comment
Share on other sites

I've never seen something about an @ in a selector. Are there any docs about it?

Edit: Found it https://processwire.com/talk/topic/3768-processwire-dev-branch/page-9#entry58722

Uh...actually, I posted that very same link (+ two other related ones) in the thread you started here: https://processwire.com/talk/topic/8244-gettotal-returns-wrong-value/?p=80042 :D

Link to comment
Share on other sites

What you are probably looking for is something like this: template=address_abo, @adrdb_multi.adrdb_location=[value=stp], @adrdb_multi.anzahl>0

thank you apeisa,  I found ryans post about database vs. in-memory selectors a bit later.

but the grouped selectors i can`t get to work. the [value=stp] is for quering a textfield "value" in the target-template of the adrdb_location pagefield. Maybe these new

selectors do not work with repeater fields? I've read something about anywhere, pagetable fields work, repeaters not?

these grouped- and subselectors would be a really benefit with in-repeater pagefields holding pages with page-fields and further values (example: a location from a page field and an amount of something in a textfield for the selected location), at the moment we query such things from the repeater-pages (under /pw/repeaters) and grab the relevant page-ids from their parents url-title or loop a few times through results of multiple queries, but with 10000+ pages this takes its time of course.

thanks, martin

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...