I have some case studies. Each case study is tagged with a particular category. Some case studies are tagged with more than one category. Here’s my blueprint:
title: Case study pages
columns:
main:
width: 2/3
fields:
category:
label: Services
type: tags
accept: options
options:
- Branding
- Digital design
- Graphic design
I’m trying to follow this video, https://www.youtube.com/watch?v=ue15rQVQCqg&list=PLTep5U-3mg9EfgnQ08XDRs4vSOmhw2JWz&index=13
Is it even possible to filter pages, when some have more than one tag?
Here’s my snippet:
<?php
$filterBy = get('filter');
$projects = page('portfolio')
->children()
->listed()
->when($filterBy, function($filterBy) {
return $this->filterBy('category', $filterBy);
})
?>
<ul class="portfolio">
<?php foreach ( $projects as $project): ?>
<li>
<a href="<?= $project->url() ?>">
<?php if ($image = $project->portfolio_thumbnail()->toFile()): ?>
<picture>
<source
srcset="<?= $image->srcset('folio-thumbnails-webp') ?>"
sizes="(max-width: 1023px) 100vw, (max-width: 2240px) 25vw, 480px"
type="image/webp"
>
<img
loading="lazy"
alt="<?= $image->alt() ?>"
src="<?= $image->resize(1120)->url() ?>"
srcset="<?= $image->srcset('folio-thumbnails') ?>"
sizes="(max-width: 1023px) 100vw, (max-width: 2240px) 25vw, 480px"
width="<?= $image->width() ?>"
height="<?= $image->height() ?>"
>
</picture>
<?php endif ?>
<p><?= $project->heading() ?><br><span class="project-title"><?= $project->subheading() ?></span></p>
<p><?= $project->category() ?></p>
</a>
</li>
<?php endforeach ?>
</ul>
But when I try the filter in the browser URL:
http://localhost:8888/current-site3/about?filter=branding
The list of pages disappear.
I probably need the ‘,’ comma separation to separate the tags, but I don’t know where to put it.