I’ve been using the EasyBlog theme for one of the sites I’m working on, and one of the features I like is the “All Topics” partial which adds a list of tags at the bottom of the front page. I wanted to have this also on other pages, but in a smaller area next to the post.
Expected behaviour: adding the {{> all-topics}} partial would display all the tags from the website
Actual behaviour: adding {{> all-topics}} only displays the tags of the current post, or stays empty if it has none
I tracked this to the {{#each tags}} code block within the partial. If this is used outside of the {{#post}} block, then it contains all the tags. If used inside of it, the post’s tags overwrite them!
There doesn’t seem to be any solution to this using the Publii tools and provided helpers. I was able to work around with a bit of a kludge, but I’d rather not have to do that — I think the solution would be to have the main/root tags array be named something different so it doesn’t clash, or otherwise the {{#post}} one (though that will require more changes to templates). Could you look into fixing this?
Until then, here is how to work around it in a pinch:
- Add a custom Handlebars helper in a helpers.js override file:
- Save the tags before being overwritten by adding this bit at the very top of post{-boxed}.hbs, before {{#post}}:
- Change the {{#each tags}} line wherever needed to be instead:
If there is any more information I can provide, just let me know.