Weblog Category Heading Tag

The purpose of this tag is to show the currently viewed category as a heading.

{exp:weblog:category_heading}

<h1>{category_name}</h1>

{if category_description}
<p>{category_description}</p>
{/if}

{/exp:weblog:category_heading}

When you visit on one of your category links, your weblog entries are shown sorted by the chosen category. This tag lets you dynamically show the name of the category being viewed.

If no categories are being shown, the tag will not show anything contained within the opening and closing pair.

Parameters

disable=

disable="category_fields"

The disable= parameter allows you to turn off aspects of the tag that you might not be using in order to improve performance. Valid options are:

relaxed_categories=

relaxed_categories="yes"

This parameter allows you use the category indicator in your URLs with an entries tag specifying multiple weblogs that do not share category groups.

weblog=

weblog="news"

The name (short name) of the weblog that the categories are assigned to. Note: Unless you are using the relaxed_categories parameter, you can only list one weblog name, since each weblog can have separate category groups.

You must specify this parameter if you use the category name in URL feature.

Variables

category_description

{category_description}

This variable simply displays the content from the "category description" field. The variable may also be wrapped in a conditional statement so that it only displays if there is content in the field:

{if category_description}{category_description}{/if}

category_id

{category_id}

The category ID associated with the category.

parent_id

{parent_id}

The category ID associated with the category's parent (or 0 in the case of a top level category).

category_image

{category_image}

The image link (or other information) you can optionally store with each category within the Control Panel.

category_name

{category_name}

The name of the category being viewed

category_url_title

{category_url_title}

This variable displays the URL title of the category

Custom Category Fields

All custom fields assigned to a category can be accessed using the "short name" of the field:

{class}
{extended_description}
{category_name_fr}
etc..

These are totally dynamic in that any field you create for your category will automatically be available by its "short name" as a variable.

Top of Page

User Contributed Notes

Posted by: Shane Robinson on 2 October 2008 8:49pm
Shane Robinson's avatar

Our client has a Category template that displays multiple lists of entries from different weblogs that belong to that category. The first list is limited to 4 entries and then a link to a template that displays a paginated list of entries in that Weblog for that single Category.

If that first list doesn’t contain entries in that Category, then we don’t want to show the link.

AND, sometimes the Client wants to change the display name of the Category but not the Actual Category Name so we use the Category Description, if it exists, for display on the site….. Long story…

Anyway, was able to craft this link to the Single Category Listing Template with the following nested tags. Posting it here as I couldn’t find an example of what we needed to do in the Docs or Wiki.

{exp:weblog:category_heading weblog="{theWeblog}" relaxed_categories="yes" disable="category_fields"}
{exp
:weblog:entries weblog="{theWeblog}"  category="{category_id}" limit="1" disable="category_fields|member_data|pagination|trackbacks"}
    
<a href='http://www.domain.com/Template_Group/Category_URL_Indicator/{categories show="{category_id}"}{category_url_title}{/categories}/'>
        
See more Articles on {if category_description}{category_description}{if:else}{category_name}{/if}
    
</a>
{/exp:weblog:entries}
{
/exp:weblog:category_heading}

You can see how it works by clicking on any of the “Ready by Category” links in the right column. “Region” is the Category URL Indicator on this site because other areas of the site used “Region” as the category first.

You can see the first list shows a limit of 4 results from the A+I weblog in a given Category. The rest of the page displays a paginated list of “Results from the Blog.” So the first list is displayed, or not, based on the existence of segment_4 or segment_4 containing the value “P0” in case the user paginates to Page 1.

As of this writing, A+I doesn’t have any entries beloging to the Engagement Party category and so the link doesn’t display since it’s contained in the Category Heading tag.

You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide