Category not found
Closed this issue · 3 comments
gvanto commented
I have under my theme pages/blog/category.htm the following (as per docs):
(blog list + post pages are working fine)
title = "Category"
url = "/blog/category/:slug/:page?"
layout = "default"
[blogPosts]
categoryFilter = ":slug"
==
function onEnd()
{
// Optional - set the page title to the category name
if ($this->category) {
$this->page->title = $this->category->name;
}
}
==
{% if not category %}
<h2>Category not found</h2>
{% else %}
<h2>{{ category.name }}</h2>
{% component 'blogPosts' %}
{% endif %}
I have two published posts, each with a category assigned.
But on the blog/category/{category} page, I am getting 'No category' found.
Any help much appreciated,
G
daftspunk commented
Here is the code that loads the category:
blog-plugin/components/Posts.php
Lines 234 to 249 in b8afc17
In this case, you need to tweak the page settings to use an external parameter. It looks like this:
[blogPosts]
categoryFilter = "{{ :slug }}"
I hope this helps!
gvanto commented
Works now, thanks! (I think the docs need updating though: https://octobercms.com/plugin/rainlab-blog > Documentation)
daftspunk commented
Thanks! Updated the docs too