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).
- in the chapter, "Movable Type"
- tagged with archive, breadcrumbs, categories, children, parent, subcategories
(Minutia)
- Author:Jesse
- Published:Sep 9, 2007
- Chapters:
- Previous:
- Next:
GetUpdated
ElseWhere
AllChapters
- 2 articles in the chapter Accessibility
- 7 articles in the chapter Announcements
- 1 articles in the chapter App
- 2 articles in the chapter Apple
- 5 articles in the chapter Blogging
- 7 articles in the chapter CMS
- 1 articles in the chapter Code
- 3 articles in the chapter CSS
- 16 articles in the chapter Design
- 2 articles in the chapter DIY
- 4 articles in the chapter Downloads
- 2 articles in the chapter Freebies
- 2 articles in the chapter Gadgets
- 1 articles in the chapter Javascript
- 5 articles in the chapter Journeys
- 1 articles in the chapter Miscellany
- 1 articles in the chapter Mobile
- 59 articles in the chapter Movable Type
- 1 articles in the chapter Photography
- 2 articles in the chapter Plugins
- 1 articles in the chapter Print
- 3 articles in the chapter Projects
- 2 articles in the chapter Reviews
- 2 articles in the chapter SEO
- 10 articles in the chapter Social Networking
- 1 articles in the chapter Standards
- 4 articles in the chapter Writing
ReaderFavorites
- CSS Image Framing
- Tools of the Web Design Trade, Pt.1: Where to Begin
- Social Networking Is Killing My Ability To Write
- 10 Tips For Creating Website Mockups In Photoshop
- MobileMe vs. Dropbox
- 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

















