Most of blogers have the recent entry list at the sidebar. Sometime it's difficult to...
Most of blogers have the recent entry list at the sidebar. Sometime it's difficult to balance spacing and convenience. People may want more entries in the list, but they may also want to see other feature area without rolling scrollbar too much. I wrote a Javascript postroll.js that make the entry list rollable as far as you expect.
How does it work? Download postroll.js to your web server path and include it in your web page that you need the feature. Then edit your tempate like below. The template code is a little thick but works.
<h2>最近更新|Recent Entries</h2>
<div id="recententry" class="module-content">
<ul id="recententry1">
<MTEntries lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTEntries>
</ul>
<MTEntries offset="5" lastn="1">
<MTIfNonEmpty tag="EntryTitle"><$MTSetVar name="recententry2" value="1"$></MTIfNonEmpty>
</MTEntries>
<MTIf name="recententry2">
<ul id="recententry2">
<MTEntries offset="5" lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTEntries>
</ul>
</MTIf>
<MTEntries offset="10" lastn="1">
<MTIfNonEmpty tag="EntryTitle"><$MTSetVar name="recententry3" value="1"$></MTIfNonEmpty>
</MTEntries>
<MTIf name="recententry3">
<ul id="recententry3">
<MTEntries offset="10" lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTEntries>
</ul>
</MTIf>
<MTEntries offset="15" lastn="1">
<MTIfNonEmpty tag="EntryTitle"><$MTSetVar name="recententry4" value="1"$></MTIfNonEmpty>
</MTEntries>
<MTIf name="recententry4">
<ul id="recententry4">
<MTEntries offset="15" lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTEntries>
</ul>
</MTIf>
<MTEntries offset="20" lastn="1">
<MTIfNonEmpty tag="EntryTitle"><$MTSetVar name="recententry5" value="1"$></MTIfNonEmpty>
</MTEntries>
<MTIf name="recententry5">
<ul id="recententry5">
<MTEntries offset="20" lastn="5">
<li><$MTInclude module="Entry Link"$></li>
</MTEntries>
</ul>
</MTIf>
<label id="recententrybar1"></label><label id="recententrybar2"></label>
<!--end #recententry-->
</div>
The emphasis must be followed in your code, otherwise need to configure yours in postroll.js.
// Configuration
Postroll = {
box: ["recententry"],
bar1: ["recententrybar1"],
bar2: ["recententrybar2"],
bar1_txt: " « ",
bar2_txt: " » ",
bar1_lnk_title: "Previous 5 entries",
bar2_lnk_title: "Next 5 entries"
};
Then have this style in the css. I don't use script to initial the style because this method is quicker for the page first loading. There won't be a long entry list at a moment then hided by the script. I use script to initial the text link for rolling entries and control the entry roll after all stuffs were loaded.
#recententry2,
#recententry3,
#recententry4,
#recententry5 {
display: none;
}
There's more action you need to take if want it works perfect! Create a file name as ie_onload.js, and have below only line. About ie_onload.js here's an explanation.
try{Postroll.run()}catch(e){}
This script is able to serve multi-area in one page. That case you should have the configuration like below. It could be 3 groups or more.
// Configuration
Postroll = {
box: ["recententry", "othertag"],
bar1: ["recententrybar1", "othertagbar1"],
bar2: ["recententrybar2", "othertagbar2"]
bar1_txt: " « ",
bar2_txt: " » ",
bar1_lnk_title: "Previous 5 entries",
bar2_lnk_title: "Next 5 entries"
};
Update 2007-02-14
I found that there's one post missed on each 5 posts in the postroll list. The point is that I had wrong offset value in MTEntries tag. I've updated the template code above from offset="6" to offset="5" and also for the value of 11, 16 and 21.
Posted by Alex at 1:44 AM
| Comments (0)
| Edit | Taged: Javascript (5), MT (25)