Hey hey,
I am using a filter menu to provide an easy way for people to find projects within there area of interest. Some projects have multiple categories. Can someone help me applying that on my filter?
The absolute optimum would be to have the option to select several categories in the filter and then all projects are displayed that contain at least one of the entered categories. Is that possible?
This is the code im using right now for the filter (without multiselect) …
$filterBy = get ('filter');
$unfiltered = $page
->children()
->listed();
$projects = $unfiltered
->when($filterBy, function($filterBy) {
return $this->filterBy('category', $filterBy);
});
$filters = $unfiltered->pluck('category', ',', true);
… and this the code for the filter buttons.
<div class="filter">
<div class="reset-filters">
<a href="<?= $page->url() ?>">Reset Filters</a>
</div>
<?php foreach ($filters as $filter): ?>
<a class="<?= $filterBy === $filter ? 'active' : '' ?>"
href="<?= $page->url() ?>?filter=<?= $filter ?>">
<?= $filter ?>
</a>
<?php endforeach ?>
</div>
Thank you very much, Simon