hey,
i have a question regarding tags in kirby:
the child pages of a page have a structured field including tags. on the frontend i want to parent page to output all the childs with the corresponding tags as class and the tags as select field.
right now i have the following set up which causes some problems:
- tags aren’t plucked to a single instance. if two children have the same tag, the tag is displayed twice.
- the tags aren’t “slugged” so ists hard to filter for them.
blueprint:
stations:
label: Audiostation
type: structure
style: table
fields:
station_text:
label: Text
type: textarea
station_tags:
label: Tags
type: tags
index: all
php for filtering
<div class="filter">
<h2><?php echo l::get('topics') ?>:</h2>
<select class="filter__selector">
<option value="all"><?php echo l::get('choose') ?></option>
<?php foreach($page->children()->visible()->filterBy('translationComplete', '1') as $child): ?>
<?php $stations = $child->stations()->toStructure();
$categories = $stations->pluck('station_tags', ',', true);
foreach($categories as $category):
$filteredProjects = $stations->filterBy('station_tags', $category, ',');?>
<option value="<?= $category ?>"><?= $category ?></option>
<?php endforeach ?>
<?php endforeach ?>
</select>
thanks for any help!