Jump to content

Recommended Posts

Posted

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?

Posted

[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!

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
  • Recently Browsing   0 members

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