boris
1
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!
boris
2
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?
boris
4
It works, when I hard set the variable $name;
What could be the problem with
$name = param('tag');
?
Are you using multi-word tags?
boris
6
no, it’s one word like “Abfindung”
But I guess your page UID is “abfindung” not “Abfindung”?
$name = str::lower(param('tag'));
boris
8
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