给mt增加了随机文章MTRandomEntries插件

一直使用的是相关文章插件。但似乎相关文章,显示的总是当前页面生成时,最新发表的3篇文章。。。
 
所以增加这个随机文章插件,目的是增强网站内部的联系。
安装很简单,只需要下载之后,解压到MT的plugins目录即可。然后在模版添加下面的代码:
<MTRandomEntries category="Gaming" lastn="5">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a>:<br />
<$MTEntryExcerpt$><br />
</MTRandomEntries>
注意,其中的Gaming是你需要显示的分类名称。

然而我发现如果不加分类名称,就会出错。官方的解释是:

Container tag for the random entries that acts like MTEntries
If used within MTCategories , the random entries are chosen from current category.
If used within MTEntries , MTEntry , an Individual Archive, etc. or anything that contains an entry, the random entries are chosen from the categories of the current entry, OR-ed together.
It takes the following arguments:
category: Restrict the list of entries from which the random entries are chosen to those in specific categories. You can either supply a specific category, or use AND or OR like in MTEntries
lastn: Generate n random entries, defaults to 1

所以,我将该代码之外,使用<MTCategories></MTCategories>来包含。
不过似乎这个插件很不完善,这样做了之后,会在我的每一个分类之中,挑选一篇文章显示出来,非常恐怖。。。我只能把它加在右面了。
 
ps:似乎安装了这个插件之后生成速度明显变慢。原因是每生成一个页面,对我来说,都需要从我所有文章中随机挑选23篇文章。。。。

Leave a Reply

Your email address will not be published. Required fields are marked *