Sorry to bump this up again: I had this a while ago (Tags: list results of all existing pages), and with Kirby 2 it worked like a charm, but now, updating to Kirby 3, I cannot make it work, even if I don’t see too many differences in the code. Maybe something got lost with all the cop&paste back and forth:
So this is what I have:
The article.php:
<div class="tag">
<?php foreach($page->tags()->split(',') as $tag): ?>
<a <?php e($tag == urlencode(param('tag')), '') ?> href="<?= url('results/tag:' . $tag)?>"><?= $tag ?></a>
<?php endforeach ?>
</div>
Everything looks fine here.
The results.php controller according to the cookbook (“Controlling the filter by URL”)):
<?php return function($site, $pages, $page) {
// fetch the basic set of articles
$articles = $site->index()->filterBy('template', 'article');
// add the tag filter
if($tag = param('tag')) {
$articles = $articles->filterBy('tags', $tag, ',');
}
return compact('articles');
};
?>
And here is the results.php that is meant to display the titles of all the articles that have a certain tag in common:
<div class="content">
<?php
$tag = param('tag');
?>
<h3 class="tag-title"><?= param('tag'); ?></h3>
<?= $page->text()->kirbytext() ?>
<?php foreach($articles as $article): ?>
<div class="tag-list">
<div class="tagdate"><?= $article->date()->toDate('%d. %B %Y') ?></div>
<div class="result"><a href="<?= $article->url() ?>"><?= $article->title()->html() ?></a></div>
</div>
<?php endforeach ?>
</div>
What happens is that in the new result-page, coming from a tag-link on an article page, only the h3-title is displayed, but not the umlaut nor an empty space. The rest: date and titles of the articels don’t appear at all. I wonder what I am doing wrong…