Hi,
I’d like to work with tags and subtags.
The first page tag would be the main one, and the following ones would be the sub-tags.
Example for an article: first tag-> “News”, second tag → “News subtag”
Example for another article: first tag-> “Events”, second tag → “Events subtag”, third tag → “Events subtag 2”
How can I change my code here to fetch only first tags in the filter menu?
And then under each filter menu <li>
fetch all the tags that are coming in second but have the same first tag? Would that be possible?
<?php
$filterBy = get('filter');
$unfiltered = $page->children()->sortBy('date', 'desc');
$chronicles = $unfiltered
->when($filterBy, function($filterBy) {
return $this->filterBy('Tags', $filterBy, ',');
});
$filters = $unfiltered->pluck('Tags', ',', true);
?>
<?php foreach ($filters as $filter): ?>
<li class="<?= $filter ?>">
<a href="<?= $page->url() ?>?filter=<?= $filter ?>"><?= $filter ?></a><span></span>
</li>
<?php endforeach ?>
Thanks in advance for the help.
Bests