Created
April 6, 2012 00:24
-
-
Save anonymous/2315384 to your computer and use it in GitHub Desktop.
how to filter by tag params?
This file contains hidden or 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 | |
/* WHRE DO I PUT THE FOLLOWING CODE SO THAT /blog/tag:SomeTagName works? | |
When I click on a tag link, it still displays all the articles even if the tags don't match. | |
*/ | |
if(param('tag')) { | |
$article = $pages->find('blog') | |
->children() | |
->visible() | |
->filterBy('tags', param('tag'), ',') | |
->flip() | |
->paginate(10); | |
} else { | |
$article = $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($page->children()->visible()->flip() 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