Ordering Categories in MT 3.2
I wanted to custom order my categories and subcategories however, by default, MT is ordering the categories alphabetically and there are not any tag filters to change this behavior. So, I searched the forums and Web for a possible solution to this problem. One of the solutions was to name your categories “1. Category1”, “2. Category2”, and so on. However, this solution was not applicable for the Setup32.com Web site because I’ll miss some important keywords (SEO related) in the link anchor to the category as well in the URL for the category archive. For example, in regards with SEO “Windows 2000” and “1. Windows 2000” are two completely different things. The first one is a great key phrase, and the second one… well, it would be good if a user search for exactly the same phrase – “1. Window 2000”.
The second solution is to use the Brad Choate's MTRegex plugin to search and replace the extra numbers in the beginning of the category label.
You can find some of the examples published here and here. I decided to modify and adopt the sample regex to my own needs. I named my directories using the following pattern:
01. cat1 02. cat3 03. etc.
Then, I have used the following code to display the categories and subcategories:
<MTIfArchiveTypeEnabled archive_type="Category">
<MTTopLevelCategories>
<MTSubCatIsFirst>
<ul class="module-list">
</MTSubCatIsFirst>
<MTIfNonZero tag="MTCategoryCount">
<li class="module-list-item">
<a href="<$MTCategoryArchiveLink$>"
title="<$MTCategoryDescription$>">
<MTCategoryLabel regex="s|^([\d\d\.\s]*\s*)||"></a>
<MTElse>
<li class="module-list-item">
<MTCategoryLabel regex="s|^([\d\d\.\s]*\s*)||">
</MTElse>
</MTIfNonZero>
<MTSubCatsRecurse>
</li>
<MTSubCatIsLast>
</ul>
</MTSubCatIsLast>
</MTTopLevelCategories>
</MTIfArchiveTypeEnabled>
You should apply the regex filter for your archive paths too:
I used the following for the individual archive:
<MTParentCategories glue="/"> <$MTCategoryLabel regex="s|^([\d\d-]*\s*)||" dirify="1"$> </MTParentCategories>/%b.html
And the following for the category archive:
<MTParentCategories glue="/"> <MTCategoryLabel dirify="1" regex="s|^([\d\d\.-]*/*\s*)||"> </MTParentCategories>/index.html
You can notice that the actual regex is slightly different for the archive paths. This is because of the additional dirify filter used in the MTCategoryLabel tag.
Now, what the above codes produce? For example, I have a category named Installation and Configuration with a sbcategory Active Directory. These categories are named
------ 02. Installation and Configuration |- ------ |- ------ |- 03. Active Directory
In the categories list displayed on the site they appear as Installation and Configuration and Active Directory respectively, and the ULS to the archives are http://www.setup32.com/windows-2000-resource-guide/installation-and-configuration/ and http://www.setup32.com/windows-2000-resource-guide/installation-and-configuration/active-directory/
Nice, huh?