I installed a clean copy of EE v7.5.12 with the default themes included. The blog code is not working as I expected. To try it out, I started by going to the Blog channel in the CP and turning on the blog category group. Then I went to the categories and added descriptions to some of them. Finally, I edited several of the blog entries to add them to a category.
What’s Working When I go to the the front end of the site and click on the blog link, I see the channel title (actually the p_title set in the template) and the channel description (also set in the template) followed by the full list of entries. When I select a category from the list of categories, the list of entries is reduced down to only those entries assigned that category.
What’s Not Working Although the channel title and description vanish as they should, they are not replaced by the category name and channel. Here is the code from the blog/index template that I think should be doing that.
{!-- Heading output is different in the case of category listings. --}
{if segment_2 == 'category'}
{layout:set name='cat_ch' value='{ch}'}
{exp:channel:category_heading channel='{ch}'}
<h1>{category_name}</h1>
{if category_description}
{category_description}
{/if}
{/exp:channel:category_heading}
{if:else}
<h1>{p_title}</h1>
{p_description}
{/if}From what I’ve read in the documentation an in the forums, that should work the way I expected and display the category name in the headline and the description in the paragraph, but it doesn’t. I’ve done quite a bit of experimentation and determined that anything I put between the opening and closing exp:channel:category_heading tags will not be displayed, and I don’t know why.
Can anyone explain why this code (which came with the EE install) isn’t working?
Can anyone tell me how to make it work?
Thank you.
I think the channel:category_heading tag only works when:
You’re on a category archive page.
EE recognizes the correct segment format: /template_group/template/category/cat_url_title/
In your case, make sure the URL is like this:
/blog/index/category/news/segment_2 == ‘category’ (true)
segment_3 == ‘news’ (category URL title)
If you’re missing the third segment, category_heading has no data to pull from.
Foodle is a word-guessing game with a gastronomic theme. Instead of providing hints to your partner, you are required to describe the cuisine in a manner that enables them to identify it.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.