froot Posted September 29, 2020 Posted September 29, 2020 I have pages with multiple "categories". Those categories derive from a multiple value selector field. I want to be able to turn on or off single categories in general, so that when I do, the pages that have that category will not be selected when I select them (unless the page in question belongs to another category that is active.) Hope I made my point clear? So I put the selector field on the parent page as well. How can I manipulate the array according to whichever values are selected on the parent-page? either with selector? something like… $all_categories = $pages->get('/portfolio/')->get('category'); $works = $pages->get("template=work, category=$all_categories") // compare array on page with the array on the parent page or first compare the two arrays and build another array where I only add the results where the array intersect. So I think what I'm asking is: what is the API-equivalent for array_intersect to use with a WireArray?
froot Posted September 29, 2020 Author Posted September 29, 2020 [SOLVED] answering my own thread, maybe it'll help someone in the future. I went with: foreach ($works as $work) : if ($all_categories->has($work->category) == true) : // put markup here endif; endforeach; …which works as a charm, cheers!
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