Creative Ways To Use Subcategories
Create a “Breadcrumb” Trail In Movable Type Using Subcategories
Quandary: Someone clicks on a subcategory archive, but it looks just like every other category page. How can we give the user a better sense of context for the subcategory pages?
Solution: Breadcrumbs! You know, they look like: Category » Subcategory , with links that let us get around a complex hierarchy pretty easily. Put this code where your category title gets displayed:
<mt:HasParentCategory>
<mt:ParentCategories exclude_current="1">
<a href="<mt:CategoryArchiveLink/>"><mt:CategoryLabel /></a>
</mt:ParentCategories> »
</mt:HasParentCategory>
<mt:ArchiveTitle />
Essentially, we check to see if the category page we’re on has a parent. If it does, we append the title with that parent category name (exclude_current hides the subcategory we’re in) and link so the user can jump back pretty quickly.
Display Subcategories As A Menu On A Category Archive Page
Quandary: You got several categories with subcategories, and you’d like to show these subcategories as a menu on the parent category archive page.
Solution: This is a little tricky because all subcategories are categories too. So you have to think more in terms of relationships to tackle this one. Here’s the code:
<mt:HasSubCategories>
<ul>
<mt:SubCategories>
<li><a href="<mt:CategoryArchiveLink/>"><mt:CategoryLabel /></a></li>
</mt:SubCategories>
</ul>
</mt:HasSubCategories>
<mt:HasParentCategory>
<mt:ParentCategories exclude_current="1">
<mt:HasSubCategories>
<ul>
<mt:SubCategories>
<li><a href="<mt:CategoryArchiveLink />"><mt:CategoryLabel /></a></li>
</mt:SubCategories>
</ul>
</mt:HasSubCategories>
</mt:ParentCategories>
</mt:HasParentCategory>
The first chunk says, “If this category has subcategories (children), then run through the list of them and create a menu.” This part targets the parent category pages, because they have children.
The second chunk is similar, but it’s meant for the subcategory pages themselves. This code says, “If this category has a parent category, then give us a list of subcategories (children) that belong to that parent and make a menu.” Since Movable Type doesn’t have any type of sibling tags, we have to go back to a parent if it exists and then display that parent’s children (those are the siblings).
- Comments (1)
- in the chapter, "Movable Type"
- tagged with archive, breadcrumbs, categories, children, parent, subcategories
InterAction:
YourThoughts?
(Minutia)
- Author:Jesse
- Published:Sep 9, 2007
- Chapters:
- Previous:
- Next:
GetUpdated
ElseWhere
AllChapters
- 2 articles in the chapter Accessibility
- 6 articles in the chapter Announcements
- 4 articles in the chapter Blogging
- 7 articles in the chapter CMS
- 1 articles in the chapter Code
- 3 articles in the chapter CSS
- 15 articles in the chapter Design
- 4 articles in the chapter Downloads
- 1 articles in the chapter Freebies
- 1 articles in the chapter Gadgets
- 4 articles in the chapter Journeys
- 1 articles in the chapter Miscellany
- 59 articles in the chapter Movable Type
- 2 articles in the chapter Plugins
- 1 articles in the chapter Print
- 1 articles in the chapter Projects
- 2 articles in the chapter SEO
- 6 articles in the chapter Social Networking
- 1 articles in the chapter Standards
- 1 articles in the chapter Writing
BiteSize.blog
ReaderFavorites
- CSS Image Framing
- Tools of the Web Design Trade, Pt.1: Where to Begin
- Tools of the Web Design Trade, Pt.2: Building Trust
- 10 Tips For Creating Website Mockups In Photoshop
- Movable Type As A Desktop App
- Redesign, Part 1: The Logo
- Redesign, Part 2: Stylesheet Philosophy
- The Social Graph in Plain Language
- Writing Your Own Autobiography: The New Persistence of Information
- Designing eComm 2008


















19 February 20091. Josh Rubin:
This is really helpful, thanks! I'm still struggling with an issue and would love any insight you can offer.
I have three levels of categories, let's call them Main, Subcategory and Section. Ever Main category has Subcategories and some Subcategories have Sections. The hierarchy looks something like:
Main
Subcategory
Section
Section
Section
Subcategory
Subcategory
Section
Section
Subcategory
Main
Subcategory
Subcategory
Section
Section
Section
Section
Subcategory
Main
Subcategory
Subcategory
Section
Section
Subcategory
Subcategory
Subcategory
Section
Section
When viewing any listing page I want to show the Subcategories that correspond to that page's Main category. Easy enough. When viewing a Subcategory's listing page I want to show that Subcategory's Sections nested in the menu below the active Subcategory. This display should also apply when viewing the Section's listing page.
I have tried the following, but the result is that the Sections list for all Subcategories and the Section's listing pages don't show the parent Subcategories:
">
I have also tried this, but the Sections are listed outside of their parent Subcategory and can not be styled differently:
Fiduciary Trust International
Any ideas??
Thanks!
Josh