Displaying related entries in Movable Type
in Movable Type
I want to display list of entries under one category. I want to take advantage of Movable Type Dynamic Publishing.
I remembered that Jay Allen gave a template tag few months ago. After searching in Pastie (pastie: hi)!, I found the code.
Okey, here is the code (I cleaned it up a little bit):
<ul> <MTEntryCategories> <MTEntries lastn="3"> <li><a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a></li> </MTEntries> </MTEntryCategories> </ul>
If I put this in my individual archive template, I will have a list of entries related to the entry category. It does the trick. But, there was a problem when an entry was assigned to some categories. I use lastn="3" attribute to display only last three entries. if an entry as assigned to more than one category, e.g. Category A, Category B and Category C, I will have 9 entries displayed. I only wanted to display similar entries, based on the primary category.
I had a short discussion with Arvind Satyanarayan and Girlie about this. Girlie suggested MTRelatedEntries plugin. It does not work with dynamic publishing. And, she suggested me to use Smarty. Oh my, I am no Smarty expert. But, I gave it a try. This is the code I use:
{{capture assign="category"}}<$MTEntryCategory$>{{/capture}}
<ul>
<MTEntries lastn="3" category="`$category`">
<li><a href="<$MTEntryPermalink$>" title="<$MTEntryTitle$>"><$MTEntryTitle$></a></li>
</MTEntries>
</ul>
It works without problem. Great! The above tips has been tested in Movable Type 3.34 with dynamic publishing.








