Using IfArchiveType to display keywords on Entry pages

Some times it is easy to find useful code snippets for Movable Type, sometimes not. I had always wondered how you would intelligently include META information (specifically keywords), and after a few tries, and looking through the tag reference on MT.org, I found IfArchiveType.

Starting the mt:if statement off with IfArchiveType is important because IfArchiveType itself is a block tag. I also am using BlogID and some global and local template modules. Hit the jump for the code an a short description

<mt:IfArchiveType type="individual">
	<meta name="keywords" content="<$mt:EntryKeywords$>" />
	<meta http-equiv="author" content="<$mt:EntryAuthorDisplayName$>" />
	<meta http-equiv="email" content="<$mt:EntryAuthorEmail$>" />
<mt:ElseIf tag="BlogID" eq="9">
	<meta name="keywords" content="<$mt:Include module="META Keywords"$>" />
	<meta http-equiv="author" content="<$mt:Include module="META Author"$>" />
	<meta http-equiv="email" content="<$mt:Include module="META Email"$>" />
<mt:ElseIf tag="BlogID" eq="27">
	<meta name="keywords" content="<$mt:Include module="META Keywords"$>" />
	<meta http-equiv="author" content="<$mt:Include module="META Author"$>" />
	<meta http-equiv="email" content="<$mt:Include module="META Email"$>" />
<mt:Else>
	<meta name="keywords" content="<$mt:Include module="BGV Keywords"$>" />
	<meta http-equiv="author" content="<$mt:Include module="BGV Author"$>" />
	<meta http-equiv="email" content="<$mt:Include module="BGV Email"$>" />
</mt:IfArchiveType>

This is what I am doing for the BG Views project for Student Publications. The "BGV" template modules are global. In every blog in the site, I have a set of "META" template modules. The statement knows which one to use because BlogID puts them in context. Keeping them the same also makes scaling the if statement dead-on simple.

Now your Entry pages will have keywords, author, and email coming from the entry in question, other pages in the blog will have relevant META tags, and everything else that is not specified uses the global template modules.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Blog Hosting by Meancode Media



Breaking Windows is © 2003
by Ken Edwards and Matt Paprocki. Some Rights Reserved.
Contact Ken: ken [at] meancode [dot] com
Contact Matt: videogamer [at] bex [dot] net

Disclaimer: The opinions expressed on this website are solely those of the author and do not reflect those of any corporation, business entity, group or club the author has ever been associated with. Feel free to quote anything I say but do me the courtesy of a link back (see Creative Commons license).

Blogcritics Magazine

Social Networking

Mac Headlines

Read up-to-date headlines on everything Mac.

Content provided by prMac.

ESRB Search

Creative Commons License
This weblog is licensed under a Creative Commons License.
Enhanced with Snapshots