Jump to content

Selectors in combined / merged arrays


Bacelo
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...