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$>"> «
<$MTCategoryLabel$></a> |
</MTCategoryPrevious>
<a href="<$MTBlogURL$>">Main</a>
<MTCategoryNext> |
<a href="<$MTCategoryArchiveLink$>">
<$MTCategoryLabel$>
»</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 URL for this entry:
http://bradchoate.com/mt/feedback/tb/433
Listed below are links to weblogs that reference Supplemental Category Tags:
» 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]
» 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 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]
» 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]
» 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]
» カテゴリーã”ã¨ã«ãƒ‡ã‚¶ã‚¤ãƒ³ã‚’変ãˆã‚‹ï¼‘ from *hanakonet- home -ã‚·ãƒ§ãƒƒãƒ”ãƒ³ã‚°ãƒ»æ˜ ç”»ã‚„ãŠè–¦ã‚商å“ã®ç´¹ä»‹ã‚„ã‚¢ãƒ¼ãƒˆã‚®ãƒ£ãƒ©ãƒªãƒ¼ãƒ»ãƒ›ãƒ¼ãƒ ãƒšãƒ¼ã‚¸ç´ ææŽ²è¼‰ã®ãƒãƒŠã‚³ãƒãƒƒãƒˆ
movabletypeã®å…ƒã®ã¾ã¾ã ã¨ã€ã‚«ãƒ†ã‚´ãƒªãƒ¼ãƒ†ãƒ³ãƒ—レートã«ãƒ‡ã‚¶ã‚¤ãƒ³ãªã©è¨å®šã—... [Read More]
» カテゴリーã”ã¨ã«ãƒ‡ã‚¶ã‚¤ãƒ³ã‚’変ãˆã‚‹ï¼‘ from *hanakonet- home -ã‚·ãƒ§ãƒƒãƒ”ãƒ³ã‚°ãƒ»æ˜ ç”»ã‚„ãŠè–¦ã‚商å“ã®ç´¹ä»‹ã‚„ã‚¢ãƒ¼ãƒˆã‚®ãƒ£ãƒ©ãƒªãƒ¼ãƒ»ãƒ›ãƒ¼ãƒ ãƒšãƒ¼ã‚¸ç´ ææŽ²è¼‰ã®ãƒãƒŠã‚³ãƒãƒƒãƒˆ
movabletypeã®å…ƒã®ã¾ã¾ã ã¨ã€ã‚«ãƒ†ã‚´ãƒªãƒ¼ãƒ†ãƒ³ãƒ—レートã«ãƒ‡ã‚¶ã‚¤ãƒ³ãªã©è¨å®šã—... [Read More]
» カテゴリーã”ã¨ã«ãƒ‡ã‚¶ã‚¤ãƒ³ã‚’変ãˆã‚‹ã€€ï¼‘ from *hanakonet- home -ã‚·ãƒ§ãƒƒãƒ”ãƒ³ã‚°ãƒ»æ˜ ç”»ã‚„ãŠè–¦ã‚商å“ã®ç´¹ä»‹ã‚„ã‚¢ãƒ¼ãƒˆã‚®ãƒ£ãƒ©ãƒªãƒ¼ãƒ»ãƒ›ãƒ¼ãƒ ãƒšãƒ¼ã‚¸ç´ ææŽ²è¼‰ã®ãƒãƒŠã‚³ãƒãƒƒãƒˆ
ã¾ãšã€ãƒšãƒ¼ã‚¸ã‚’ãれãžã‚Œã«è¡¨ç¾ã—ãŸã„時ã¯è¤‡æ•°ã‚¦ã‚§ãƒ–ãƒã‚°ã‚’作ã£ã¦ã€ä¸€ã¤ã«è¦‹ã›ã‚‹æ–¹æ³•ã¨... [Read More]
Great! thank you :)
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. ???
Nico-- The 1.1 update takes care of this.
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.
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!
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!
The MTIfCategory tag dies if there are posts with no categories set (including the primary category). I got this error on rebuilding:
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.
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!
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?
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...
Must you convert your blog to .php for this to work? Or can it be .html?
Thank you. =)
Yes, this plugin works with regular .html files.
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 :)
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
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?
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)