Show text as Filtermenu Label

Hey,

is ist possible to show the text as label in Filtermenu?

categories:
  type: select
  options: query
  query: 
    fetch: site.categories.toStructure
    text: "{{ structureItem.category }}"
    value: "{{ structureItem.category_url }}"

I also tried

categories:
  type: select
  options: 
    gaerten: Gärten
    parks: Parks

and

categories:
  type: select
  options: 
    - value: 'gaerten'
      text: Gärten
    ...

The filtermenu should use labels like: Gärten | Parks
The url/filter should use the value ...?filter=gaerten

<?php

$filterBy = get('filter');
$unfiltered = $page->children()->listed();
$projects= $unfiltered
  ->when($filterBy, function($filterBy) {
    return $this->filterBy('categories', $filterBy);
  });

$filters = $unfiltered->pluck('categories', ',', true);
?>

<nav>
  <a href="<?= $page->url() ?>">All</a>
  <?php foreach ($filters as $filter): ?>
    <a href="<?= $page->url()?>?filter=<?= $filter ?>"><?= $filter ?></a>
  <?php endforeach ?>
</nav>

I don’t know exactly what’s missing/wrong with the filter-controller.

Thank you.

For the hard-coded values, you have two options:

  1. Manually create a category map in your config with key/value pairs
  2. Reading the blueprint ($page->blueprint()): Using blueprints in the frontend | Kirby CMS

With the dynamic ones from the field, get the text from the categories structure field in your site.

Hey @pixelijn thank you very much for the help.

Where I have to do that?

In your template, where you want to fetch this value…

Sorry, the question was worded incorrectly. Where in the template?
In the filter controller?
In the filter menu?
And how can I fetch the text: "{{ structureItem.category }}" for the label
and the value: "{{ structureItem.category_url }}" for the filter-url.