display categories in category archive

I want to display a list of categories in a sidebar on my Category Archive Template page. If I enter the code from the Main Index, my category archive sidebar comes up empty (literally, it displays nothing under the categories heading). To fix that, I am calling that same code into my category archive template as a php include.

Create a new index template called categories.php and place in it the sidebar code (from main index template) for your CATEGORIES:

<MTSubCategories> <MTSubCatIsFirst><ul></MTSubCatIsFirst> <MTIfNonZero tag="MTCategoryCount"> <li><a href="<$MTCategoryArchiveLink$>" title="<$MTCategoryDescription$>"><MTCategoryLabel></a> <MTElse> <li><MTCategoryLabel> </MTElse> </MTIfNonZero> <MTSubCatsRecurse max_depth="3"> </li> <MTSubCatIsLast></ul></MTSubCatIsLast> </MTSubCategories>

In your Category Archive template, place the following code:


<div id="categories">
<h2>MTInclude Categories</h2>
<$MTInclude file="categories.php"$>
</div>

This should display your category heirarchy just as in the main index. You could also use this method to display recent entries here. I do believe the entire sidebar code would work in your category archive using this method.

(extended entry below is my former not-so-brilliant method... don't bother reading it)


<div id="categories">
<h2>Categories</h2>
<ul>
<MTEntryCategories blog_id="n">
<li><a href="<$MTCategoryArchiveLink$>" title="<$MTCategoryDescription$>"><MTCategoryLabel></a>
</li>
</MTEntryCategories>
</ul>
</div>

where "n" (above) equals your blog_id number. (obviously!) If you remove the blog_id from this code, it will return categories from all the blogs on your installation.

Mind you, I consider this a temporary solution and will continue to work on this as time permits. Note that this ONLY displays non-empty categories and in non-heirarchical fashion (no subcategories).

See newer, better solution at top of this entry.

About this Entry

This page contains a single entry by Kate published on March 5, 2005 9:55 AM.

customize comment notification email was the previous entry in this blog.

displaying code in entries is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.