Supplemental Category Tags

Here's a little plugin that provides some new Category tags for Movable Type.

Availability

You can download this plugin from here: mtcatx-1_5.zip

Requirements

The following are requirements for using this plugin:

  • Movable Type 2.21 or later
  • MT-Regex (if using the 'pattern' attribute of the IfCategory or IfPrimaryCategory tag).

Installation

To install, place the 'catx.pl' file in your Movable Type 'plugins' directory. The 'catx.pm' file should be placed in a 'bradchoate' subdirectory underneath your Movable Type 'extlib' directory. Your installation should look like this:

  • (mt home)/plugins/catx.pl
  • (mt home)/extlib/bradchoate/catx.pm

Description

This plugin provides additional tags for Movable Type categories.

Tags made available through this plugin:

  • <MTCategoryNext>: Container tag for finding the next category relative to the current entry category or archived category.
  • <MTCategoryPrevious>: Container tag for finding the previous category relative to the current entry category or archived category.
  • <MTIfCategory>: Used to output content if the current category (in the context of a category archive template) matches a given name or pattern. Or if used within the context of an entry, will compare against all the categories assigned to that entry.
  • <MTIfPrimaryCategory>: Much like 'IfCategory', but only compares with an entry's primary category.
  • <MTEntryAdditionalCategories>: Similar to the Movable Type 'MTEntryCategories', but only lists secondary categories.

<MTCategoryNext>, <MTCategoryPrevious>

Attributes

  • show_empty: Set to '1' to allow the selection of emtpy categories.

Usage

Here's the snippet you would add to the default Category Archive template (place right above the <MTEntries> tag):

  <div id="menu">
  <MTCategoryPrevious>
  <a href="<$MTCategoryArchiveLink$>"> &laquo;
  <$MTCategoryLabel$></a> |
  </MTCategoryPrevious>
  <a href="<$MTBlogURL$>">Main</a>
  <MTCategoryNext>  |
  <a href="<$MTCategoryArchiveLink$>">
    <$MTCategoryLabel$>
  &raquo;</a>
  </MTCategoryNext>
  </div>

The next and previous category is selected based on alphabetic order.

<MTIfCategory>, <MTIfNotCategory>, <MTIfPrimaryCategory>, <MTIfNotPrimaryCategory>

Attributes

  • name: Used to compare against a specific category name.
  • pattern: Compares the category name(s) to a regular expression (requires the MT-Regex plugin).

Usage

  <MTIfCategory name="Special">
    <img src="images/special.gif" align="right" />
  </MTIfCategory>

<MTEntryAdditionalCategories>

Attributes

  • glue: Separator to place inbetween multiple categories.

Usage

  Also filed under:
  <MTEntryAdditionalCategories glue="; ">
    <$MTCategoryLabel$>
  </MTEntryAdditionalCategories>

License

Released under the MIT license. Please see
    http://www.opensource.org/licenses/mit-license.php
for details.

Changelog

  • 1.5: Added 'Not' support for IfCategory, IfPrimaryCategory tags.
  • 1.4: Added 'EntryAdditionalCategories' container tag.
  • 1.3: Added 'IfCategory', 'IfPrimaryCategory' tags.
  • 1.2: Explicity sorting category list by label now.
  • 1.1: The 'Next' and 'Previous' tags now exclude empty categories by default. The 'show_empty' attribute was added to allow them to be selected.
  • 1.0: Initial release

TrackBack

TrackBack URL for this entry:
http://bradchoate.com/mt/feedback/tb/433

Listed below are links to weblogs that reference Supplemental Category Tags:

» Supplemental Category Tags from nico | couchblog
Endlich: Brad Choate erweitert die MT-Tags um <MTNextCategory> & <MTPreviousCategory>. Installieren! [Read More]

» Etiquetas de Categorías Adicionales from blog-e-ando
Supplemental Category Tags. Spanish translation. Etiquetas de Categorías Adicionales. Traducción al castellano. [Read More]

» Brad Choate scares me from gnawing ideas
Yes, he does. Another one of these guys that literally solve problems for me before I can even think to [Read More]

» This doesn't help matters... from gnawing ideas
No it doesn't. I expressed a certain level of fear over the near clairvoyant introduction of the Supplemental Category Tags [Read More]

» supplemental category tags plugin from Girlie's Tips and Tricks
How did I miss this one? Brad must have snuck it by me! Check out Supplemental Category Tags. Gives you [Read More]

» Category Tags from I Whispered...
Brad has once again come up with a fabulous new plugin: Supplemental Category Tags. They allow you to use Category [Read More]

» Previous/Next from ***Dave Does the Blog
I make it a habit of checking out Brad Choate's Hello, World site at least once a week. He's one [Read More]

» Plugin: Category Extension from Site Log
Keeping it organized. [Read More]

» movable type update from stuck-on-mobile-e-com ;-)
i just finished reading mark pilgrims 30 days to a more accessible web page and started integrating most tips he made (astonished that moveable type includes already quite a lot of his suggested changes) then i went over to andersja's blog and started ... [Read More]

» Neat MT Plug-In from LilacRose
I was wondering if there was a way to have previous/next category links on the category archive pages. After poking [Read More]

» This doesn't help matters... from divagation.com: 2002
No it doesn't. I expressed a certain level of fear over the near clairvoyant introduction of the Supplemental Category Tags... [Read More]

» Brad Choate scares me from divagation.com: 2002
Yes, he does. Another one of these guys that literally solve problems for me before I can even think to... [Read More]

» nickname tagline from Al-Muhajabah's Movable Type Tips
In the "posted by" tagline below each post I include a nickname for myself, which differs based on category. When I post to A Quranic Journal, the nickname is "a student of the Quran"; when I post to The Clipboard,... [Read More]

» Previous/Next from ***Dave Does the Blog
I make it a habit of checking out Brad Choate's Hello, World site at least once a week. He's one... [Read More]

» Different archives from XIDER
I've just managed to give the photos' category archives a different look from the ones with text only, using Brad... [Read More]

» Category Extensions from About
Brad Choate's Category Extensions is a great tool. Perhaps the most useful feature, or most used, is the Previous and Next category container tags, but there are other useful tags in it. Check it out.... [Read More]

» using key values to store additional information from Al-Muhajabah's Movable Type Tips
The Key Values plugin offers one way to store more information with each entry than you have fields for. I use it on The Clipboard to create the "Other Views" section. There are several services such as Blogdex, Waypath, and... [Read More]

» Back Online from LANGUAGEMAVEN
I have rebuilt the design from the ground up...again. I used a couple plugins for some of the features I... [Read More]

» MT Plugins Installed from Technology Updates
The following MovableType plugins were installed: From Brad Choate IncludeEx - Improves on MT’s Include tag by processing the included file for MT tags. MTAuthors - This plugin allows you to list the authors for your blog. You can also... [Read More]

» Templating MFop2 from daveXtreme
When I bought my new cell phone last month, the store had a bundle deal for an attachable camera at 50% off. Half-off is a good deal, but that would have still meant spending $50 for the camera. And while... [Read More]

» Supplemental Category Tags for Movable Type from Pick A Bar
I spent today bashing my head against technology and my own stupidity. In the morning I realized that I'd forgotten... [Read More]

» Supplemental Category Tags from Paul's Blog
Yet another new tool has been added to my blog. I've added Brad Choate: Supplemental Category Tags to the collection. This plugin enables Next and Previous in my Category Archives pages. I was looking for a way to do this,... [Read More]

» Enhancing Category Tags from Don't Back Down
I recently stumbled across David Raynes' excellent SubCategories plugin. This plugin allows you to define existing categories as parents and children of one another. For instance, I have a Movable Type category. This category has been defined as a pare... [Read More]

» MT:前/次のカテゴリーへリンク from ウェブログ@ことのは [weblog@kotonoha]
 Movable Typeはデフォルトで、各個別の記事ファイルから「前の登録項目(エントリー)」「次の登録項目」へのリンクが付くようになっている。これと似たことがカテゴリー書庫ファイル... [Read More]

» Installed Supplemental Cateogory Tags from Living Dead Girl
By Brad Chaote. Here’s a little plugin that provides some new Category tags for Movable Type.... [Read More]

» Redesign Will Always Be in Progress from Thinkless
Redesign is more or less done. [Read More]

» MT Plugins from Opinion
A couple more MT plugins from the prolific Brad Choate have been added to the system. First is Sanitise, which allows unwanted HTML to be stripped from comment displays. This was due to a problem caused by a closing tag being cropped by the recent comm... [Read More]

» MT Plugins from Opinion
A couple more MT plugins from the prolific Brad Choate have been added to the system. First is Sanitise, which allows unwanted HTML to be stripped from comment displays. This was due to a problem caused by a closing tag being cropped by the recent comm... [Read More]

» MT Plugins from Opinion
A couple more MT plugins from the prolific Brad Choate have been added to the system. First is Sanitise, which allows unwanted HTML to be stripped from comment displays. This was due to a problem caused by a closing tag being cropped by the recent comm... [Read More]

» more LJ/MT crossposting from Silently - s p e a k i n g
OK someone asked me how I was excluding some posts... [Read More]

» MT Supplemental Category Tags from Mind of Knowledge
Brad Choate: Supplemental Category Tags... [Read More]

» MT Plugins from Opinion
A couple more MT plugins from the prolific Brad Choate have been added to the system. First is Sanitise, which allows unwanted HTML to be stripped from comment displays. This was due to a problem caused by a closing tag being cropped by the recent comm... [Read More]

» MT Plugins from Opinion
A couple more MT plugins from the prolific Brad Choate have been added to the system. First is Sanitise, which allows unwanted HTML to be stripped from comment displays. This was due to a problem caused by a closing tag being cropped by the recent comm... [Read More]

» Archives and postcards from FultonChain
This site is well past the thousand entry mark and it really isn't practical to display the full content of each post in the category archives -- a couple of the categories run about 300 entries each. However, I found... [Read More]

» Navigating Through MT Photo Galleries from Thinkless Static
In our previous installment we learned how to set up photo galleries in Movable Type. Once you've added a few galleries, you may begin to notice that whatever you use for navigation is completely incoherent. Movable Type doesn't provide an... [Read More]

» About the Site from Thinkless Static
A colophon of sorts. [Read More]

» [plugin]-Supplemental Category Tags from £µ£°¡ó£µ£°¡ó-hanhan-
¥«¥Æ¥´¥ê¤´¤È¤Ë°ã¤¦ÆâÍƤòɽ¼¨¤µ¤»¤ë¥×¥é¥°¥¤¥ó [Read More]

» ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»ƒƒ‚@1.ƒJƒeƒSƒŠ[•Ê‚̃fƒUƒCƒ“ from KillerPierce
‚¹‚Á‚©‚­MT‚ð‚â‚Á‚Ä‚¢‚é‚ñ‚¾‚©‚ç‚ƁA“ú‹L‚¾‚¯‚Å‚È‚­ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»‚µ‚Ä‚µ‚Ü‚¢... [Read More]

» ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»ƒƒ‚@1.ƒJƒeƒSƒŠ[•Ê‚̃fƒUƒCƒ“ from KillerPierce
‚¹‚Á‚©‚­MT‚ð‚â‚Á‚Ä‚¢‚é‚ñ‚¾‚©‚ç‚ƁA“ú‹L‚¾‚¯‚Å‚È‚­ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»‚µ‚Ä‚µ‚Ü‚¢... [Read More]

» ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»ƒƒ‚@1.ƒJƒeƒSƒŠ[•Ê‚̃fƒUƒCƒ“ from KillerPierce
‚¹‚Á‚©‚­MT‚ð‚â‚Á‚Ä‚¢‚é‚ñ‚¾‚©‚ç‚ƁA“ú‹L‚¾‚¯‚Å‚È‚­ƒTƒCƒg‚Ü‚é‚Ü‚éMT‰»‚µ‚Ä‚µ‚Ü‚¢... [Read More]

» カテゴリーごとにデザインを変える1 from *hanakonet- home -ショッピング・映画やお薦め商品の紹介やアートギャラリー・ホームページ素材掲載のハナコネット
movabletypeの元のままだと、カテゴリーテンプレートにデザインなど設定し... [Read More]

» カテゴリーごとにデザインを変える1 from *hanakonet- home -ショッピング・映画やお薦め商品の紹介やアートギャラリー・ホームページ素材掲載のハナコネット
movabletypeの元のままだと、カテゴリーテンプレートにデザインなど設定し... [Read More]

» カテゴリーごとにデザインを変える 1 from *hanakonet- home -ショッピング・映画やお薦め商品の紹介やアートギャラリー・ホームページ素材掲載のハナコネット
まず、ページをそれぞれに表現したい時は複数ウェブログを作って、一つに見せる方法と... [Read More]

» MovableType3プラグイン from Dreamagic! DEV.
 Dreamagic!では次のようなプラグインを利用しています。これらのプラグイ... [Read More]

» カテゴリーごとにデザインを変える 1 from *hanakonet*- ほっこり暮らす
まず、ページをそれぞれに表現したい時は複数ウェブログを作って、一つに見せる方法と... [Read More]

» カテゴリーごとに異なる表示や動作をさせる方法 from Vinyl Lab.
MovableTypeで、カテゴリーごとに異なる表示や動作をさせる方法。 [Read More]

» MT-モブログで複数の添付画像を横に並べる from 秀ボーの詩的関心事
 京ぽんからのメールに複数の画像を添付してモブログでページを更新する設定をしてい... [Read More]

» MovableType:カテゴリー毎に表示を変更するプラグイン from Check it
MovableTypeでは、メインページ、カテゴリーアーカイブ、個別エントリー... [Read More]

20 Comments

bmk said:

Great! thank you :)

Nico said:

Hey Brad!

Nice Tags, I've been waiting for this long time, so thanx for this one.

But: is it a bug or a feature: if you have categories with nothing in it, they are also displayed, and (as there is nothing in, there's no archive-page for them) the link point to an error page (not found), certainly. ???

Brad Choate said:

Nico-- The 1.1 update takes care of this.

rayne said:

I tried this plugin...it's great...except that it doesn't list my categories alphabetically. I am not sure how it is picking them up but I'm not getting the next and prev category that would fall alphabetically.

Is this a bug? I copied the code directly from the example. (I've taken off my site till I understand how it is working.)

Thanks!

Just a guess, but it appears (I say appears) to be linking between my categories in the order they were created.

Brad Choate said:

rayne, Damelon: yes, that was a bug. 1.2 fixes that. Either mysql was sorting alphabetically for me or I haven't added any new categories since my Berkeley DB-to-mysql conversion (assuming that it created the categories in alphabetic order during the conversion). In any case, I didn't see any problem with the ordering myself. Try 1.2 out and see if it fixes yours.

Well, thanks for fixing it so fast, but I wasn't complaining. I had actually noticed the order it was displaying in and it didn't strike me as a pressing issue. Considering your lightning turnaround I was just going to let it be for a couple days. I would have mentioned it Monday or so, but I wasn't worried about any programming evil on your part. Have a nice weekend!

rayne said:

Brad, thanks for getting that fixed so quickly!

Great job on the category tags. Just curious tho: is there a way to use this with the MTElse tags?

Thanks again for the quick response on the forums!

Michael Stucker said:

The MTIfCategory tag dies if there are posts with no categories set (including the primary category). I got this error on rebuilding:

Build error in template 'Main Index': Error in tag: Error in tag: You used an tag outside of the proper context.

It doesn't really stop me from doing anything (all of my posts should have at least one category), but I thought you might like to know.

Chris Bishop said:

You are a genius!

Once again I think, "I wish MT could do this..." I come to your site and you have created a plugin for exactly what i need. Keep up the good work!

Mike said:

Is there a way to negate the name value for the IfCategory and IfPrimaryCategory tags?

I would like to wrap my entry section in the main index in these to avoid posting a certain category to the main index. Can this be done like this or should I be doing it a different way?

Tony said:

I think you can use the glue attribute instead of the name attribute in IfCategory to do an all but one inclusive. Or you could hack it...

Christine said:

Must you convert your blog to .php for this to work? Or can it be .html?
Thank you. =)

Brad Author Profile Page said:

Yes, this plugin works with regular .html files.

melanie said:

is there a way I can use this in combination with something so I can have two instructions, eg






I'm already using php to use different stylesheets depending on the entry category, but using php in the templates leaves huge empty amounts of whitespace. And I don't like that :)

Jeff Beer said:

Hi Brad,

Thanks for the great info and the tools.

Any chance you'll be adding a <MTIfCategoryElse> or <MTIfCategoryDefault> tag - something as a catchall if the If's fall through? I'm going to use this with a dynamic template module loader and am too lazy to create a template for every category...

Thanks again,

Jeff Beer

Jay Allen said:

Hey Brad,

There's no reason why this plugin should not affect Archive File Templates is there?

I am trying to write out individual archives into a directory structure that follows one of two patterns:

1) /category/title
2) /category/subcategory/title

There will always be a category and title and only sometimes a subcategory. When there is a subcategory, there will only be one.

Hence, in my archive file template for my individual archive looks like this relative to blog root (line feeds for readability):

<$MTEntryCategory dirify="1"$>/
<MTIfNotEmpty var="EntryAdditionalCategories">/<$MTEntryAdditionalCategories$>/</MTIfNotEmpty>
<$MTEntryTitle dirify="1"$>

I know I need to dirify the secondary category, but for now, I am just trying to get the above to work... It ain't...

Instead, I am gettnig fun errors like these upon rebuild:

MT::App::CMS=HASH(0x835fd58) Use of uninitialized value in concatenation (.) or string at /home/jallen/www/mt-staging/extlib/File/Spec/Unix.pm line 78.
MT::App::CMS=HASH(0x835fd58) Use of uninitialized value in hash element at /home/jallen/www/mt-staging/lib/MT.pm line 396.
MT::App::CMS=HASH(0x835fd58) Use of uninitialized value in hash element at /home/jallen/www/mt-staging/lib/MT.pm line 306.

Any ideas?

Thanks for creating this very useful plugin. Any chance you could add a 'MTCategoryFirst' and 'MTCategoryLast' feature?

Morten Rønnelund said:

MTs own MTElse doesn't seem to work within MTIfCategory - are you aware of this?

I'm trying:

MTIfCategory name="Hot Topic" -> Show special graphic
MTElse -> Show normal grapchic
/MTElse
/MTIfCategory

Also - this doesn't work:

MTIfCategory name="Hot Topic" -> Show special graphic
/MTIfCategory

MTIfNotCategory name="Hot Topic" -> Show normal graphic
/MTIfNotCategory

Hot Topic entries show have boths "graphics", while all others have none at all.

Sollution?

--
Morten, Denmark
(you're welcome to contact me directly by email)

About

This article was published on October 31, 2002 11:55 PM.

The article previously posted was Movable Type 2.51 Released.

The next article is Linux for Windows?.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type