Is there a way to include multi-word tags, e.g. apps, Mac Mini, technology (Mac Mini in this case)?
Seems the only way is to use an underscore, Mac_Mini.
Is there a way to include multi-word tags, e.g. apps, Mac Mini, technology (Mac Mini in this case)?
Seems the only way is to use an underscore, Mac_Mini.
No, you can use multi-word tags without problem. You would only have to urlencode()
and urldecode()
them again.
Thanks, texnixe.
Is there a snippet of code of that? Presumably it has to go in the ‘article.php’ template. At the moment I have:
<?php
$count = 0;
foreach ($tags = explode(",", $page->tags()) as $tag) {
$count++;
// NOTE: added / before blog
echo '<a href="'.url().'/blog/tag:'.urlencode(trim($tag)).'">'.str_replace('-',' ', $tag).'</a>';
if ($count != count($tags)) {echo ',';}
}
?>
<?php $tags = $page->tags()->split() ?>
<ul class="tags inline-list">
<?php foreach($tags as $tag): ?>
<li><a href="<?php echo url('blog/tag:' . urldecode($tag))?>"><?php echo $tag ?></a></li>
<?php endforeach ?>
</ul>
And in your blog.php controller:
if(param('tag')) {
$tag = urldecode(param('tag'));
$articles = $page->children()->visible()->filterBy('tags', $tag,',')->sortBy('date');
} else {
$articles = $page->children()->visible()->sortBy('date', 'desc');
}