« New Layout (Again) | Main | MT-Email »
March 17, 2003
CategoryHeaderFooter
In a little email conversation with Ben earlier today, I was inspired to write another plugin: CategoryHeaderFooter.
CategoryHeaderFooter provides tags that will return header/footer text depending on the current entry's category (or just upon the current entry if within MTCategories).
Download:
Install:
- Unpack archive
- Place categoryheaderfooter.pl in your plugins/ directory
Usage:
- To set Headers/Footers:
- Create a template using the following tags (the DEFAULT category is for entries with no category):
<MTCategorySetHeaderFooter
category="Example Category"
header="<h2>Example Category Header</h2>"
footer="Free to use, publish, and reproduce">
<MTCategorySetHeaderFooter
category="DEFAULT"
footer="Wahoo!">
-
- Build the template
- You're done (the headers and footers are stored in the MT datastore, so they don't need to be re-set with each rebuild of the other templates)
- To access the Headers/Footers:
- MTCategoryHeader will return the header for the current category
- MTCategoryFooter will return the footer for the current category
- The current category will be taken from the current category if within MTCategories, or if that is not the case, the tags will take the primary category from the current entry
- Example:
<MTEntries lastn="15">
<MTEntryTitle>
<MTCategoryHeader>
<MTEntryBody>
<MTCategoryFooter>
</MTEntries>
Big Update: (to v 0.2)
- Removed MTCategorySetHeaderFooter in favor of new container tags MTCategorySetHeader and MTCategorySetFooter, which are able to re-set data in the database. They both take one argument: category which must be defined.
- Changed 'DEFAULT' to 'NONE' (no category)
- 'DEFAULT' is now for categories (including NONE) without header/footer currently set
- Header and Footer may now contain any and all MT Template Tags, e.g.:
<MTCategorySetHeader category="DEFAULT">
<MTEntries lastn="5">
Entry Title: <$MTEntryTitle$>
</MTEntries>
</MTCategorySetHeader>
Posted by rayners at March 17, 2003 01:14 PM
Trackback Pings
TrackBack URL for this entry:
http://mt.rayners.org/mt-tb.cgi/165
Listed below are links to weblogs that reference CategoryHeaderFooter:
» CategoryHeaderFooter from MT Plugin Directory
[Read More]
Tracked on March 11, 2003 10:39 PM
» MT, PHP, CSS News Roundup from hebig.org/blog
MOVABLE TYPE Joi Ito's mail2entry is a Python script that allows to post MT entries containing text and images via [Read More]
Tracked on March 13, 2003 05:41 AM
» MT, PHP, CSS News Roundup from hebig.org/blog
MOVABLE TYPE Joi Ito's mail2entry is a Python script that allows to post MT entries containing text and images via [Read More]
Tracked on March 13, 2003 02:08 PM
» MT, PHP, CSS News Roundup from hebig.org/blog
MOVABLE TYPE Joi Ito's mail2entry is a Python script that allows to post MT entries containing text and images via [Read More]
Tracked on March 13, 2003 04:14 PM
Comments
Can you delete the template that sets the headers and footers after you've rebuilt it?
Posted by: Al-Muhajabah at March 11, 2003 10:38 PM
i'm getting the following error: An error occurred: Can't locate MT/PluginData.pm in @INC (@INC contains: ./extlib ./lib /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/siteperl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/siteperl/5.8.0 /usr/lib/perl5/siteperl /usr/lib/perl5/vendorperl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendorperl/5.8.0 /usr/lib/perl5/vendorperl .) at lib/MT/App/Vote.pm line 7. BEGIN failed--compilation aborted at lib/MT/App/Vote.pm line 7. Compilation failed in require at mt-vote.cgi line 17.
what's this?? help me plz! siavash
Posted by: siavash at March 18, 2003 08:54 AM
sorry. i forgot to say, it's about mt-vote script that you made!!! siavash
Posted by: siavash at March 18, 2003 08:55 AM
Have any updates been made to this plugin recently? I've found information about this plugin posted in serveral different places and I wanted to make sure I wasn't missing out on the latest code. It's an awesome concept and I'm hoping to use it in two of my blogs. Thanks! Laura
Posted by: Laura at April 12, 2003 09:41 AM
i have a question (and i don't know much about plugins, so bear with me): under usage, it says "the headers and footers are stored in the MT datastore, so they don't need to be re-set with each rebuild of the other templates." does that mean if you built the template once and you want to change it, you can't? because i've tried changing and rebuilding but my pages are still not looking right. (great plugin by the way - my own ignorance is really the reason for my problems)
Posted by: Rachel at June 10, 2003 11:36 PM
Question: I might not be reading this correctly, but what I'm trying to do is what they're doing over at Up2Speed, by having "Category(s): category1, category2"
Is that what this plugin does? Or can I do that without it?
Posted by: trepryor at July 7, 2003 03:33 PM
This is pretty confusing now with the comment on the update. I have no idea which one to use now, and whether I have to create a template module or an index template, and whether it need to be an "output file" or not.
Apart from that I have a request. I'd like to try this plugin out, but I seem to not get it work. But what I wanted to try to do with it anyway is to add additional different texts on my different category archives depending on what category it is. Can I do that with this plugin, or does it only work for entries?
If it only works for entries, can you create one for category archives with a more exact explanation for people that are not advanced?
Posted by: Michelle at September 6, 2003 05:03 PM
First, thanks for the plugin. It's just what I was looking for. I use it for generating different menus for categories.
One question though: How do I rebuild the content that is generated, i.e. the stuff between and ? I managed to do it by including the module template that contains the code in my main template, but then it printed the "Header for '$cat_label' saved" in my pages. A simple way to rebuild would be nice!
Posted by: MoeGreene at September 7, 2003 02:44 PM
First, thanks for the plugin. It's just what I was looking for. I use it for generating different menus for categories.
One question though: How do I rebuild the content that is generated, i.e. the stuff between and ? I managed to do it by including the module template that contains the code in my main template, but then it printed the "Header for '$cat_label' saved" in my pages. A simple way to rebuild would be nice!
Posted by: MoeGreene at September 7, 2003 02:44 PM
First, thanks for the plugin. It's just what I was looking for. I use it for generating different menus for categories.
One question though: How do I rebuild the content that is generated, i.e. the stuff between and ? I managed to do it by including the module template that contains the code in my main template, but then it printed the "Header for '$cat_label' saved" in my pages. A simple way to rebuild would be nice!
Posted by: MoeGreene at September 7, 2003 02:44 PM
I get this error message:
"Can't call method "data" on an undefined value at .../mt/plugins/categoryheaderfooter.pl line 40. "
Any ideas?
Posted by: John Moore at October 14, 2003 11:27 AM
Hi John, I encountered the same problem. I posted the fix that worked for me in the MT forums. Here's what it said:
"I'm no coding expert but I seemed to have fixed this to enable it to run for me so I thought I'd share in case it works for others. I was getting an error in line 40 of the script I downloaded (V1.2). The error was: "Can't call method "data" on an undefined value at plugins/categoryheaderfooter.pl line 40." And Line 40 of the code reads:
return '' if (!$headerData || (!exists $header->data->{header}));
I changed it to read:
return '' if (!$headerData || (!exists $headerData->data->{header}));
and everything now runs fine. Very cool plugin."
I hope this solves the problem for you too,
Laura
Posted by: Laura at October 15, 2003 04:21 PM
Okay, this is really cool. It seems like you could use this in category archives to set up different templates for each category; I can't wait to play with it!
When do the MT tags get processed? If you use a MT tag inside of the header, what will it do? I suppose I will just install it and find out :grin: Thanks!
Posted by: kristine at March 11, 2003 09:18 PM