Bacelo Posted September 25, 2018 Posted September 25, 2018 Hi there, I need a little help of the community as I'm walking a bit in the dark at the moment...??? I have the following code and need to add some selectors to the merged array: $termine_1 = $page->children("standort_reference~=$standort"); $termine_2 = $page->children("standort_alle=1"); $termine = $termine_1->and($termine_2); I would like to add the following selectors to merged array $termine: ("sort=date, limit=10, date>=today") How can I achive this? ??
elabx Posted September 25, 2018 Posted September 25, 2018 $termine->filter("date>=today")->sort("date")->slice(0,10) I wonder also if this could also work, I could bet it does: $termine->filter("date>=today, sort=date, limit=10"); Keep in mind filter method is destructive.
Robin S Posted September 25, 2018 Posted September 25, 2018 @Bacelo, you can do all of that more efficiently in a single selector string: $termine = $page->children("(standort_reference~=$standort), (standort_alle=1), sort=date, limit=10, date>=today"); https://processwire.com/api/selectors/#or-groups 5
Bacelo Posted September 26, 2018 Author Posted September 26, 2018 12 hours ago, elabx said: $termine->filter("date>=today")->sort("date")->slice(0,10) I wonder also if this could also work, I could bet it does: $termine->filter("date>=today, sort=date, limit=10"); Keep in mind filter method is destructive. Thank you @elabx for your help, but unfortunately that didn't worked.
Bacelo Posted September 26, 2018 Author Posted September 26, 2018 11 hours ago, Robin S said: @Bacelo, you can do all of that more efficiently in a single selector string: $termine = $page->children("(standort_reference~=$standort), (standort_alle=1), sort=date, limit=10, date>=today"); https://processwire.com/api/selectors/#or-groups @Robin S you made my day ?! That works like a charm!!!?? I tried to combine that somehow, but didn't find the right way... (and also didn't find the right selectors ? as mentioned in your posted link). I thought, that this could be combined, but so I tried to go the other way as posted in my question. Perfect - many thanks for your help - learned again something new ?? 2
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