Some time ago on this forum, I posted my "recipe" for using the Keyword field to create an open-ended, bottom-up classification scheme. I've made some tweaks to the code since then, so I thought I'd share with you.
First, you might want to read my blog post on why you might want to do this. Namely, why coding your blog using keywords can turn your blog into a semantic web that is easier for your readers to browse. This is especially useful, I think, for group blogs, but the methodology can be used on any sort of blog.
Basically, what this method does is link your blog posts together by keyword. Unlike categories, which are limited, top-down, and hierarchical, keywords are open-ended and limitless. You can see how it works on my blog, Ishbadiddle. And here's how to do it:
1. Get the Plugins
You'll need the following plugins: IfEmpty, MTLoop, Compare, and MTCollate.
Install the plugins.
2. Code your posts.
This system assumes that your keywords are formatted thusly:
CODE
Penguins, George W. Bush, New York City
Each keyword is separated by a comma and a space. Capitalization matters. Anything can go into a keyword, although &s make it go kind of wonky.
3. Make a new keyword-only search template
Next, you'll need to modify your search function so that you can limit the search to the keyword field. Follow the instructions for the hack on Stepan Riha's site.
Next you'll create a new template, just to use for keyword extraction. Get your regular search template (default.tmpl), rename it subject.tmpl. My basic code for the template is:
CODE
<MTSearchResults>
<MTBlogResultHeader>
<h2 class="date">Subject Index for <$MTSearchString$></h2>
</MTBlogResultHeader>
<div class="posts">
<h3 class="title"><a href="<$MTEntryPermalink$>"><$MTEntryTitle remove_html="1"$></a></h3>
<$MTEntryExcerpt$><br />
<span class="author"><$MTEntryAuthor$></span><span class="byline"> wrote this on <$MTEntryDate format="%B %e, %Y"$></span><br /><br />
</div>
</MTSearchResults>
<MTBlogResultHeader>
<h2 class="date">Subject Index for <$MTSearchString$></h2>
</MTBlogResultHeader>
<div class="posts">
<h3 class="title"><a href="<$MTEntryPermalink$>"><$MTEntryTitle remove_html="1"$></a></h3>
<$MTEntryExcerpt$><br />
<span class="author"><$MTEntryAuthor$></span><span class="byline"> wrote this on <$MTEntryDate format="%B %e, %Y"$></span><br /><br />
</div>
</MTSearchResults>
Of course you can change the styling for your own blog, and list the contents however you choose (full posts?)
The other addition to your keyword search template is the list of related keywords. I put this in my sidebar.
CODE
<b>Other Subjects Related to "<$MTSearchString$>"</b><br/>
<MTCollateCollect>
<MTSearchResults>
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTSearchResults>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<MTIfNotEqual a="[MTSearchString]" b="[MTCollateField name='subject_keyword']">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTIfNotEqual>
</MTCollateList>
<MTCollateCollect>
<MTSearchResults>
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTSearchResults>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<MTIfNotEqual a="[MTSearchString]" b="[MTCollateField name='subject_keyword']">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTIfNotEqual>
</MTCollateList>
This creates a list of keywords that is related to the one on the page they're looking at. It's generated by looking at all the keywords that occur in posts along with the current keyword. Fun to browse!
Upload subject.tmpl into the proper folder (see here for instructions.)
4. Create a full list of keywords
Make a new template, one that will auto-update. The following code will make a list of all the keywords used on your blog:
CODE
<h3 class="title">Subjects</h3>
<div class="posts">
<MTCollateCollect>
<MTEntries lastn="9999">
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntries>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
<div class="posts">
<MTCollateCollect>
<MTEntries lastn="9999">
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntries>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
I use similar code to create category-specific sets of keywords, which are much more browsable than the full list. This I put in a new category archive.
CODE
<h3 class="title"><$MTArchiveCategory$> Subject Index</h3>
<div class="posts">
<i>This is the list of subjects covered in <$MTArchiveCategory$> posts. You can also read <a href="<$MTBlogURL$>archives/<$MTArchiveCategory dirify="1"$>">all the posts in the <$MTArchiveCategory$> category here.</a></i>
<br/><br/>
</div>
<div class="posts">
<MTCollateCollect>
<MTEntriesWithSubCategories>
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntriesWithSubCategories>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
</div>
<br/><br/>
</div>
(Note that I'm using MTEntriesWithSubCategories here, but you don't have to.)<div class="posts">
<i>This is the list of subjects covered in <$MTArchiveCategory$> posts. You can also read <a href="<$MTBlogURL$>archives/<$MTArchiveCategory dirify="1"$>">all the posts in the <$MTArchiveCategory$> category here.</a></i>
<br/><br/>
</div>
<div class="posts">
<MTCollateCollect>
<MTEntriesWithSubCategories>
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntriesWithSubCategories>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
</div>
<br/><br/>
</div>
5. Coding your main blog
Finally, you'll want to put this code into your main blog index, as part of your code for each post within MTEntries:
CODE
<MTIfNotEmpty var="EntryKeywords"><br /><br />See also: <MTLoop values="[MTEntryKeywords]" delimiter=", "> <a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=[MTLoopValue]" title="Index of posts relating to [MTLoopValue]">[MTLoopValue]</a> |</MTLoop></MTIfNotEmpty>
That will create a list of keywords, separated by "|"s, each of which will link to a list of posts in chronological order on that subject.
Pretty neat, huh?
You'll want to include that code on your Individual Archive pages as well.
If you want to get fancy, you can create a list of recent topics for your sidebar:
CODE
<!--Recent Topics-->
<a name="recenttopics"></a>
<b>What We're Talking About Lately</b><br>
<MTCollateCollect>
<MTEntries lastn="20">
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntries>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
<a name="recenttopics"></a>
<b>What We're Talking About Lately</b><br>
<MTCollateCollect>
<MTEntries lastn="20">
<MTLoop values="[MTEntryKeywords]" delimiter=", "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTEntries>
</MTCollateCollect>
<MTCollateList sort="subject_keyword:+:i:d">
<a href="http://WWW.YOURURL.NET/mt/mt-search.pl?IncludeBlogs=1&SearchField=keywords&Template=subject&CaseSearch=1&ResultDisplay=Ascending&search=<MTCollateField name="subject_keyword">" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a><br />
</MTCollateList>
And that's it. I think there are lots of uses for this, so I wanted to share the code. Let me know if you have suggestions, questions, kudos, etc.