Hi,
I ran into something strange. I used the baseblog template as a start and modified it a bit. Everything works like a charm but when I decided not to use the blog as the homepage… the tag functionality stopped working. Although in the URL it shows the www.homepage.com/tag:something
, the template set as “home” is displayed but not the tag page. When I switch back (blog as home), everything works as expected. What am I missing here? Although the code itself works, I post it here, maybe someone can give me a hint what I will have to adjust. Thanks.
<?php if(param('tag')): // show tag results ?>
<?php $tag = urldecode(param('tag')); ?>
<?php $articles = $pages->find('publications')->children()->visible()->filterBy('tags', $tag, ',')->flip()->paginate(10); ?>
<div class="hero">
<h1>“<?php echo $tag ?>”</h1>
<div class="subtitle">Here are the publications we have found under this tag:</div>
</div>
<section class="content">
<div class="text"><?php foreach($articles as $article): ?>
<article>
<h3><a href="<?php echo $article->url() ?>"><?php echo html($article->title()) ?></a></h3>
<p>
<?php echo $article->author() ?>
</p>
</article><?php endforeach ?>
</div>
<aside class="text">
<h3>All Tags</h3><?php $tags = $page->children()->visible()->pluck('tags', ',', true); asort($tags);?>
<ul class="tagcloud"><?php foreach($tags as $tag): ?>
<li><a href="<?php echo url('publications/tag:' . $tag)?>"><?php echo html($tag) ?></a></li><?php endforeach ?>
</ul>
</aside>
</section>
<?php else : ?> // show the regular entry