I always get a 404 error (not found with this page(‘blog’).
Could the reason be my multi-language setup (EN & DE) + this config setting: ‘home’ => ‘blog’?
I had to rename ‘home’ to ‘blog’ even if the page blog has been moved to home by the mentioned config to make it work.
Only with the following addition it doesn’t work:
Probably my knowledge and understanding of PHP is far too low for this (and I really appreciate your constant support) but with this code all articles are displayed and not only the one with the tag “test”. Why is that?
But with none of the following blog.php controller code variations articles will be filtered by tags (I would expect to see only articles with the tag “test”):
<?php
return function($page, $tag) {
// fetch the basic set of pages
$articles = $page->children()->listed()->flip();
// fetch all tags
$tags = $articles->pluck('tags', ',', true);
// add the tag filter
if($tag = param('tag')) {
$articles = $articles->filterBy('tags', 'test', ',');
}
// apply pagination
$articles = $articles->paginate(5);
$pagination = $articles->pagination();
return compact('articles', 'tags', 'tag', 'pagination');
};
<?php
return function($page, $tag) {
// fetch the basic set of pages
$articles = $page->children()->listed()->flip();
// fetch all tags
$tags = $articles->pluck('tags', ',', true);
// add the tag filter
if($tag) {
$articles = $articles->filterBy('tags', 'test', ',');
}
// apply pagination
$articles = $articles->paginate(5);
$pagination = $articles->pagination();
return compact('articles', 'tags', 'tag', 'pagination');
};
Is the field name correct? Feel free to send me a download link to the project. We are currently digging in the dark, it seems, although I’m sure it’s just a little thing.
One question left: If I use the following code in the config.php to show only articles with the tag “test” on the virtual page “test” I still get all articles displayed: