« Converting Keywords into Tags | Main | How to Make a Subject Index Using Tags »

Related Tags

Movable Type 3.3 Comes with a powerful new tagging feature, the details of which Jay Allen outlines in Everyone Loves Tags.

If you have implemented MT's tagging system on your blog, and you click on a tag on an entry, it takes you to a tag search result page with a list of the entries tagged with that tag (and their excerpts), which is what you would expect. In the sidebar of the tag search result page is also listed the entire list of tags in the blog. If you have a lot of tags, say in the hundreds, you might not want them all listed out. You might just want the tags listed that are in some way related to the tag that was just clicked.

Fortunately, the TagSupplementals Plugin from developer Hirotaka Ogawa provides the ability to display related tags. (If you use this plugin, be sure to make a donation to Hirotaka's efforts using the PayPal button on his site.) Here are the steps you need to take to swap out the list of all tags for a list of only related tags:

  1. Download and install the TagSupplementals plugin.
  2. Amend the search results template. The new MT3.3 default search result template (Main Menu > Blog > Templates > System Templates > Search Results Template) includes code to display tag search results (what you get when you click on a tag displayed on the entry). The right hand sidebar of the template contains the following search code:

    <MTIgnore> ########## TAG LISTING FOR TAG SEARCH ONLY </MTIgnore>

    <MTIfTagSearch>
    <div class="module-tags module">
    <h2 class="module-header">Other Tags</h2>
    <div class="module-content">
    <p>Other tags used on this blog:</p>
    <ul>
    <MTTags>
    <li><a href="<$MTTagSearchLink$>"><$MTTagName> (<$MTTagCount$>)</a></li>
    </MTTags>
    </ul>
    </div>
    </div>
    </MTIfTagSearch>

    Swap out that code with the following:

    <MTIgnore> ########## TAG LISTING FOR TAG SEARCH ONLY </MTIgnore>

    <MTIfTagSearch>
    <div class="module-tags module">
    <h2 class="module-header">Related Tags</h2>
    <div class="module-content">
    <p>Other Subjects Related to "<$MTSearchString$>":</p>

    <MTSearchTags>

    <ul>
    <MTRelatedTags>
    <li><a href="<$MTTagSearchLink$>" rel="tag"><$MTTagName> (<$MTTagCount$>) </a></li>
    </MTRelatedTags>
    </ul>

    </MTSearchTags>
    </ul>
    </div>
    </div>
    </MTIfTagSearch>

    Note that the two closing div tags at the end of the code are for divs declared earlier in the default template.

    Save your template and rebuild your site.

Note that if you are implementing the new tagging feature on an existing pre-MT3.3 site that you have upgraded to MT3.3, I recommend testing the new tagging feature on a test weblog first. You may need to make some substantial code changes to your search templates - default and alternative if you are using alternative search templates.

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.)