« 3.16 released | Main | tag cloud »

more fun with keywords and tags

Following up on Using keywords and tags to help visitors find related content, my keyword search template now includes a list of related tags.

This is based on Ishbadiddle's semantic web idea. I've modified his code to match with the way I do my entry keywords, and am using the MT-Grid plugin to create a tabular listing of the related tags (keywords). Here's the code:

<MTCollateCollect>
<MTSearchResults>
<MTLoop values="[MTEntryKeywords]" delimiter=" "><MTCollateRecord>
<MTCollateSetField name="subject_keyword">[MTLoopValue]</MTCollateSetField></MTCollateRecord></MTLoop>
</MTSearchResults>
</MTCollateCollect>
<p><b>Other tags related to <i><$MTSearchString$></i></b></p>
<table cellspacing="0" cellpadding="10">
<MTGrid num_columns="9" transpose="1">
<MTCollateList sort="subject_keyword:+:i:d">
<MTIfNotEqual a="[MTSearchString]" b="[MTCollateField name='subject_keyword']">
<MTGridCell>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
<td><a href="<$MTCGIPath$><$MTSearchScript$>?Template=keyword&search=<MTCollateField name="subject_keyword">&IncludeBlogs=1&SearchField=keywords" title="Index of posts relating to <MTCollateField name="subject_keyword">"><MTCollateField name="subject_keyword"></a></td>
<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridCell>
</MTIfNotEqual>
</MTCollateList>
<MTGridTrailingCells>
<td> </td>
<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridTrailingCells>
</MTGrid>
</table>

(you can see the full keyword search template here)

You will need the Collate and Compare plugins in addition to the ones mentioned in my previous entry.

What it does is create a listing of all tags for all entries that are in the search results. It removes any duplicates and then the tag that is the search term itself. So what you end up with is a list of tags that were used along with the search-term tag.

An example of how this works is my list of entries tagged with iraq. You'll see a list of all entries tagged with this word and then a list of related tags. Each of these tags was used in conjunction with "iraq" to tag an entry somewhere. Clicking on the name of the tag will bring up a list of all entries that use that tag.

Comments

Glad you're finding this hack to be useful! I added your "external resources" idea to my tag pages.

One question for you -- the MTIfNotEqual used to work for me, as a way to elminate the currently referenced tag from the list of related tags. But now it doesn't work any more. Do you have any ideas on that?

Thanks!

Hi IshMEL,

Sorry for the delay in replying! The MTIfNotEqual is from a plugin, so you may want to contact the plugin developer for troubleshooting.

Hope this helps!

About This Blog

  • Disclaimer: This is a personal site and is not connected with Six Apart, Ltd, the makers of Movable Type
  • Contact me:
  • Readme: What this blog is and is not
  • Reference: Templates for Al-Muhajabah's Islamic Blogs

August 2008

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Tips by Type

Tips by Area

Other ways to read this blog

Feed Subscribe to this blog's feed
(default is RSS 2.0, I also have RSS 1.0 and Atom)

Text-only version
Powered by
Movable Type 3.2