SubCats and Contents

UPDATE: There seems to be a bug with the Sub Categories code which prevents this tutorial from working properly in static index templates. In dynamic index templates it works as it is meant to. Differences can be seen between static and dynamic

Following on from Elise's Expandable List Menus tutorial, this is a way to incorporate Sub Category relationships in your Table of Contents or other similar pages.

Add the following code to an index template wherever you want the Category/Entry list

<div class="subcats"> <MTSubCategories> <MTSubCatIsFirst><ul></MTSubCatIsFirst> <li> <h3><a href="<MTCategoryArchiveLink>"><MTCategoryLabel></a></h3> <ul> <MTEntries><li><a href="<MTEntryPermalink>"><MTEntryTitle></a></li></MTEntries> </ul> <MTSubCatsRecurse> </li> <MTSubCatIsLast></ul></MTSubCatIsLast> </MTSubCategories> </div>

If you wish to remove the bullet marks then add the following to your stylesheet

.subcats li {
    margin-top: 5px;
    list-style-type: none;
}

You can see an example on Movalog's Table of Contents

2 Comments

Mariann said:
on Sep 14, 2004 10:37 PM | Reply

Is it possible to filter only certain categories through this bit of coding? For example, I only want the parent category Module 1 and its sub-category Essay #1 to show up -- can I do that?

Dan Wolfgang said:
on Sep 21, 2004 10:50 PM | Reply

I've been screwing around with this for a while now and am not having much success. Copying and pasting the code above yields these results for me: http://www.danandsherree.com/test.php

Obviously that can't be right because no entries are listed in the categories.

Ideas?

Leave a comment

Preview