Created
June 12, 2013 19:45
-
-
Save andreasnymark/5768459 to your computer and use it in GitHub Desktop.
Blog roll. Show all post by default, to filter by tag and show archive per year. The blog is structured “…/blog/year/post”; hence the […]->children()->children()
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 | |
if(param('tag')) { | |
// all tags are linked “…/weblog/tag:example” | |
$posts = $page | |
->children() | |
->children() | |
->visible() | |
->filterBy('tags', urldecode(param('tag')), ',') | |
->flip(); | |
} else { | |
// if no tag, list all based on “…/weblog/year/article” | |
$posts = $page | |
->children() | |
->children() | |
->visible() | |
->flip(); | |
if($posts->count()==0) { | |
// if someone happens to go to “…/weblog/year” this is fallback | |
$posts = $page | |
->children() | |
->visible() | |
->flip(); | |
} | |
} | |
?> |
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 if($posts->count()!=0): ?> | |
<?php foreach($posts AS $p): ?> | |
… | |
<?php endforeach ?> | |
<?php else: ?> | |
<p>Dude, I'm not using that tag on anything. Or am I? I might, I'm so confused…</p> | |
<?php endif ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment