根据Tag来推荐是很简单的一种,可以参考的几个地方:
http://wiki.movabletype.org/Related_Entries
http://www.jimramsey.net/2008/08/adding-related-entries-to-mid-.html
http://www.devlounge.net/code/related-entries-in-movable-type
基于全文索引的相关性:
http://cxliv.org/2008/07/28/displaying_related_entries_on_your_movable_type_site.php
现在懒得增加插件,所以直接找了方便简单的使用Tag来推荐。
重点使用了devlounge.net的代码,不过之前没仔细看文章,copy过来的时候还特意做了一些代码美化,结果居然没法正常使用:
原来MT的setvarblock有bug,设置标签时这个代码块最好不要自己换行。
原文如下:
It's very important that when you type this in there are no line breaks within any of the <mt:setvarblock></mt:setvarblock> containers. In theory, you should be able to use the strip_linefeeds attribute and not worry about line breaks, but I've not had any luck with that. In fact, it's revealed a very strange bug. Rather than deal with bugs, we'll just remove the line breaks ourselves.
MT的论坛上也有相关反馈:
http://forums.movabletype.org/2008/08/error-when-rebuilding-after-ad.html
最后的代码:
<mt:EntryifTagged>
<mt:SetVarblock name="curEntry">
<mt:Entryid />
</mt:SetVarblock>
<mt:SetVarBlock name="taglist"><mt:EntryTags glue=" OR "><mt:TagName></mt:EntryTags></mt:SetVarBlock>
<mt:SetVarblock name="listitems">
<mt:Entries tags="$taglist" unique="1" lastn="6">
<mt:SetVarblock name="listEntry">
<mt:Entryid />
</mt:SetVarblock>
<mt:unless name="listEntry" eq="$curEntry">
<li> <a href="<mt:Entrypermalink />"><mt:Entrytitle /></a></li>
</mt:unless>
</mt:entries>
</mt:SetVarblock>
<mt:if name="listitems">
<div>
<h3>Related Entries</h3>
<ul>
<mt:Var name="listitems">
</ul>
</div>
</mt:if>
</mt:EntryifTagged>
--EOF--
Leave a comment