Customizing MT ind archives with PHP

All of you people that actually know PHP may want to skip this entry as what I'm about to say will probably make you cringe. You could probably do this in some frightfully easy way, but I've barely cracked my PHP book open, so this has to work for me for now.

I discovered the following PHP snippet when I implemented the show/hide script from ScriptyGoddess and I use the hell out of it throughout my site.

if ( xxx == xxx ) {

... info ...

<? } ?>

My latest bit of witchery allows me to have only certain information show up on a page. For example, the blog that publishes the static pages of the site (about, quotes, etc) and the writing in the writing section is set to individually archive entries.

The problem is that I only want a feedback form and the creative commons license info to show up for those entries tagged with the 'writing' category. So, the above php snippet to the rescue.

I added the MT category code to the Individual Archive template, but commented it out because I don't want it to show. Then I surrounded the feedback form and cc info with the following:

if (<$MTCategoryLabel$> == writing) {

... feedback form ...
... cc info ...

<? } ?>

So when the page gets published, the entry category is checked, and if it matches 'writing', the form and creative commons license info shows up.

By repeating the php snippet and changing the category type to be matched, you could have information show up for several different categories, I would imagine. Though I haven't tried this out yet.

See for yourself:
entry not tagged as 'writing'
entry tagged as 'writing' with feedback form and cc info

patricia posted 303 words at 12:01 AM on September 10, 2003 º | Print