用镜头记录,用心灵体验 | 订阅本站 | 所有笔记 | 亲和力设计 | 流量

DB2 学习笔记

博客话题:DB2,Linux,Web,业余无线电,户外,摄影,截拳道,Thankpad,其他

Movable Type

Get rollable entry list in MT - postroll.js

目录

  1. Update 2007-02-14 

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: "&nbsp;&nbsp;&laquo;&nbsp;&nbsp;&nbsp;&nbsp;",
bar2_txt: "&nbsp;&nbsp;&nbsp;&nbsp;&raquo;&nbsp;&nbsp;",
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: "&nbsp;&nbsp;&laquo;&nbsp;&nbsp;&nbsp;&nbsp;",
bar2_txt: "&nbsp;&nbsp;&nbsp;&nbsp;&raquo;&nbsp;&nbsp;",
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.

Alex's picture

my email address in picture

搜索|Search

评论|Recent Comments

按月归档|By Month

2009
07
2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

我读|My Books

我的链接|My Links

我的朋友|My Friends

Creative Commons License
This blog is licensed under a Creative Commons License.
Movable Type 4 Logo