Category Basename in Movable Type

in Movable Type

When using Movable Type, you can easily organize your entries by categories. And, if you want to have something a little bit different, you can take advantage from MTCategoryBasename. This tag will produce the dirified basename defined for the category in context.

When you make new categoris (or subcategories), your category name (or, you can call it Category Label) will be dirified automatically. For example: Your “Me and Business” category will be dirified as me_and_business. If you enable category-base archive, your archive link will be something like this: /archives/me_and_business//.

But, if you think that it is too long, you can shorten it easily. For example: business. So, rather than having /archives/me_and_business/, you can have /archives/business.


You can do something fun here. For example, in your category archive page, you want to dispaly an image that represents the category. You should pay attention on these things: Create images, and save them in a same file format as your category basename. They don’t have to be exactly the same with the category basename. To make your life easier, you can use filenames like this: icon_business.jpg, icon_entertainment.jpg.

So, in your template you can use this: <img src="/path/to/icon_<$MTCategoryBasename$>.jpg" alt="" />

You can also have some attributes. In MTCategoryBasename you can assign this attribute: separator. Valid values are “_” and “-”. Your category basename uses underscores as the default separator. If you want to change them into dashes, you should put this: <$MTCategoryBasename separator="-"$>

If you're new here, you may want to subscribe to my RSS feed go get the latest entry from your RSS reader. You can also have my contents delivered to your inbox.

Subscribe

Buy me coffee

Do you like articles and other in my blog? If you find them useful, you can support me by sending donation.