-
-
Save bastianallgeier/2318428 to your computer and use it in GitHub Desktop.
how to filter by tag params?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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