Help - Search - Members - Calendar
Full Version: How to order categories?
Movable Type Community Forum > Additional Resources > Tips and Tricks
GAZ082
Yeah, i have a number of categories and i want them ordered as i wish (not by alphabetical order).

Any suggestion?

Thanks!.
charle97
QUOTE
sort_order=``ascend|descend''
Specifies the sort order for this particular tag; this can be used to override the globally set Sort Order for Entries, set in your weblog configuration. Valid values are ascend and descend.
In this context, ascend and descend do not mean only chronological order; this attribute can be used along with sort_by (below) to sort, for example, by entry title, either A to Z (ascend), or Z to A (descend).

The default value is descend.


QUOTE
sort_by=``field name''
Sort by a field other than the Authored On Date of the entry. Valid values for field name are title, status, modified_on, author_id, or excerpt.
The most obvious use of this attribute might be to alphabetize your entries, rather than displaying them chronologically. For example, suppose that you are using Movable Type to display a dictionary site. You might wish to group your entries by letter, so you could create 26 categories, A through Z. To build a list of all of the entries in your dictionary, grouped by letter, and sorted alphabetically (assuming that you have entered the word or phrase as the title of each entry), you could do this:

CODE
<MTCategories>
<$MTCategoryLabel$><br />
<MTEntries sort_by="title" sort_order="descend">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
</MTEntries><br />
</MTCategories>
maddy
QUOTE (GAZ082 @ Apr 25 2003, 01:09 PM)
i want them ordered as i wish (not by alphabetical order)

How do you want them ordered?
maddy
Charles, I think they meant the sort order of the categories themselves, and not the entries within that category. And unless it changed in the recent version (can't be bothered upgrading just yet), the sort_order attributes don't work in a Categories or MTArchiveList list. sad.gif

This thread (and the links within it) might be useful, depending on what kind of a sort order is required. smile.gif
nednieuws
What you need to do is give MT something to sort on, in other words:

About me
Play
Work

A more sensical order would be:

1. Play
2. Work
3. About me.

There, all done!

What!? You don't like all the numbers on your pages? Download Brad's MTRegEx plugin, install it, and then, change all your
CODE
<$MTCategoryLabel encode_html="1">
into
CODE
<$MTCategoryLabel encode_html="1" regex="s/[0-9]+.[\s]*//g"$>

(This assumes you name your categories "[numbers][period][whitespace].[category name].)

Now your category names will show as before, but ordered the way you want them to be ordered!

Don't forget to add the same regex attribute to your archiving preferences too.
nednieuws
Forgot to mention this: Make sure you also put the regex attribute in your archive paths, so your folder structure stays the same.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.