Individual Intro for a tag overview page according to tag

Hello,

I’d like to realize an tag overview page, where I want to put an intro text according to the current tag.

For example:

If I open: …/overview/tag:something

I’d like kirby to show an intro text für the tag “something”.

I understand that I can read the current tag with
param('tag');

But what is the best way to store the descriptions for the tags?

Thanks!

I try something like this, but it doesn’t show anything:

<div class="intro text">

    <?php
    $name = param('tag');
    if($site->find('stichworte/'.$name)): ?>
      <p><?php echo $site->find('stichworte/'.$name)->text(); ?></p>
    <?php endif; ?>
  </div>

Is the path to the page correct? Is the name of field correct?

From your code you should have a page /content/stichworte with subpages for each tag?

It works, when I hard set the variable $name;

What could be the problem with

$name = param('tag'); ?

Are you using multi-word tags?

no, it’s one word like “Abfindung” :confused:

But I guess your page UID is “abfindung” not “Abfindung”?

$name = str::lower(param('tag'));

aaah. That fixed it. Thank you very much!

Note that if you also use multiword tags or Umlaute, you might want to use str::slug() instead.

1 Like