Forum
Changes to blog/categories
I’ve just updated a site to use the new categories and blog version, but I’m having a slight issue. I’m adding classes to each blog post in the list and colouring them depending on the category. I previously got the category in post_in_list.html using:
<perch:blog id="categories" encode="false" />
But that doesn’t seem to work anymore, it previously returned the slug (as far as I can remember) but now it returns a number (which I assume is the id of the category).
I’ve tried various alternatives, but none work.
What do I need to change it to to work with the latest version?
Have you followed the update instructions?
https://docs.grabaperch.com/addons/blog/installation/
Hello Drew,
yes I’ve followed the instructions which made the categories show when editing a blog post and shows the categories in the post itself, but the post_in_list.html template doesn’t work.
I’ve tried various things like:
But I think I’m missing something obvious somewhere.
You need to use the
<perch:categories>
tags from yourpost.html
template.Here is my post.html template:
and here is my post_in_list.html template:
If I take out suppress from the post.html template it shows the category with a link including the slug, but it doesn’t output the slug in post_in_list.html
So, in your list template, add your categories.
Thanks Drew,
it works perfectly now. I hadn’t realised it needed <perch:categories> everyone I wanted to use them, I thought it was just when setting categories, it does make sense now I think about it though.
Thanks again for all the help.