-
-
Save Flobin/08a9c185bea907a5edf7da62e30536fa to your computer and use it in GitHub Desktop.
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 | |
// https://getkirby.com/docs/cookbook/tags | |
return function($site, $pages, $page) { | |
// fetch the basic set of pages | |
$projects = page('projects')->children()->visible()->flip(); | |
// fetch the basic set of posts | |
$blogposts = page('blog')->children()->visible()->flip(); | |
// add the tag filter | |
if($tag = param('tag')) { | |
$projects = $projects->filterBy('tags', $tag, ','); | |
$blogposts = $blogposts->filterBy('tags', $tag, ','); | |
} | |
// fetch all tags | |
$tags = $projects->pluck('tags', ',', false); | |
$tags += $blogposts->pluck('tags', ',', false); | |
// apply pagination | |
$projects = $projects->paginate(10); | |
$pagination = $projects->pagination(); | |
$blogposts = $blogposts->paginate(10); | |
$pagination = $blogposts->pagination(); | |
return compact('projects', 'blogposts', 'tags', 'tag', 'pagination'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment