Play Nice

A word about the original writing found on this site

Unless otherwise noted, these are my words, ideas, thoughts and feelings. If you like them great, if you don't that's fine too.

You're welcome to quote my writing, but please make sure you include a link back to the page from which you got the material.

This work is licensed under a Creative Commons License.
Creative Commons License

Thanks,
Patricia

Briefly

[This is where the summary would go if I'd bothered to write one.]

« Week 31Last comment posted by code snippet »
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

Published 09/09/03 in Geek_Speak • | Views: 10996 times | Print

Post a comment

Commenting is not available in this blog entry.