Hi all. I have a case studies page where I loop through case studies as items. I’m using this cookbook and have barely changed a thing as it’s just what i needed. However I now want to add a second filter option, again for tags (with the name ‘type’) and have these work in conjunction with the first selection.
So for example if I have domain.co/projects/tag:london being able to also have type:commercial
as well to show both results in the one url.
Is there a demo of this floating about that I’m not aware of.
Current controller:
<?php
return function($site, $pages, $page) {
// fetch the projects
$projects = $page->children()->listed();
// fetch all tags used in projects. pluck($field, 'separator', unique)
$tags = $projects->pluck('tags', ',', true);
// add the tag filter if there is a tag in the url
if($tag = urldecode(param('tag'))) {
$projects = $projects->filterBy('tags', $tag, ',');
}
$projects = $projects->paginate(50);
$pagination = $projects->pagination();
// Return the list of projects and tags to template
return compact('projects', 'tags', 'tag', 'pagination');
};