Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Forked from anonymous/blog.php
Created April 6, 2012 09:17
Show Gist options
  • Save bastianallgeier/2318428 to your computer and use it in GitHub Desktop.
Save bastianallgeier/2318428 to your computer and use it in GitHub Desktop.
how to filter by tag params?
<?php snippet('header') ?>
<?php snippet('menu') ?>
<?php
if(param('tag')) {
$articles = $pages->find('blog')
->children()
->visible()
->filterBy('tags', param('tag'), ',')
->flip()
->paginate(10);
} else {
$articles = $pages->find('blog')
->children()
->visible()
->flip()
->paginate(10);
}
?>
<section class="content blog">
<h1><?php echo html($page->title()) ?></h1>
<?php echo kirbytext($page->text()) ?>
<!-- FOR EACH LOOP BEGIN -->
<?php foreach($articles as $article): ?>
<article>
<h1><?php echo html($article->title()) ?></h1>
<p><?php echo excerpt($article->text(), 300) ?></p>
<a href="<?php echo $article->url() ?>">Read more…</a>
<?php echo $article->tags() ?>
</article>
<?php endforeach ?>
<!-- FOR EACH LOOP END -->
<hr/>
<hr/>
<!-- CLICKABLE TAG CLOUD GENERATOR -->
<?php $tagcloud = tagcloud($pages->find('blog'), array('limit' => 20)) ?>
<ul>
<?php foreach($tagcloud as $tag): ?>
<li><a href="<?php echo $tag->url() ?>"><?php echo $tag->name() ?></a></li>
<?php endforeach ?>
</ul>
<hr/>
</section>
<?php snippet('footer') ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment