Movable Type 首页分页

| 3 Comments | No TrackBacks | Previous

  Movable Type用得久了之后才发现,想逐篇的阅读相同分类下更早的文章并不方便,用户除了点击侧边栏的 entry-basename was the previous entry in this blog 以外,也没有别的办法快速的找到前一篇文章的链接了。使用MT Pro Personal WebSite  模板的用户,文章标题下边还会有一个Previous(Classic Blog模板没有这个,MTOS使用的就是Classic Blog模板)。位置都不显眼,用起来也不方便。

  这个MT分页的方法是从Jackie那里找到的,但是他使用的是MT5的Personal WebSite 模板,我使用的是MT4的Classic Blog模板,因为这两个模板之间的差异,害得我搞了半天只把MT的首页分页搞定。

  简单说说我这个Movable Type 首页分页的方法:

  使用下面的代码覆盖掉 Index Templates 中 Main Index 模板中对应的代码(覆盖前请先做好备份),然后将 Main Index 的 Output File (输出文件)设置为index.php,将首页设置为index.php。

<div id="alpha-inner">
  <!--Pagination Code Start-->
  <mt:var name="currentp" value="0">
  <mt:var name="limit" value="10">
  <mt:var name="lastn" value="3000"><?php
$page = $_REQUEST['p'];
if (!isset($page)) { $page = 1; }
?>
  <mt:Entries lastn="$lastn">
    <mt:setvarblock name="page"><mt:getvar name="__counter__" op="mod" value="$limit"></mt:setvarblock>
    <mt:if name="page" eq="1"><mt:setvar name="currentp" op="add" value="1"><mt:if name="currentp" gt="1"><?php } ?></mt:if><?php if ($page == <$mt:var name="currentp"$>) { ?></mt:if>
    <mt:Ignore><!-- Use the Entry Summary module for each entry published on this page --></mt:Ignore>
    <$mt:include module="Entry Summary"$>
    <mt:if name="__last__"><?php } ?></mt:if>
  </mt:Entries>
  <div id="content-nav">
<?php
$limit = <mt:var name="limit">;
$page_count = <mt:var name="currentp">;
if ($page < $page_count) {
  echo '<div class="pagination_left"><a id="next-page" href="?p='.($page + 1).'">&laquo; Older Posts</a></div>';
}
if ($page > 1) {
  echo '<div class="pagination_right"><a id="prev-page" href="?p='.($page - 1).'">Newer Posts &raquo;</a></div>';
}
?>
  </div>
  <!--Pagination Code End-->
</div>

  只解决了首页,感觉还不错,归档页面分页以后有时间再弄吧 - -!!! 。拷贝代码的时候建议使用Syntax Highlighter自带的拷贝到剪贴板的功能复制代码,以免出错。

本文结束。

No TrackBacks

TrackBack URL: http://www.sothink.cn/cgi-bin/mt-tb.fpl/55

3 Comments

im ilover. do u recognise me ?

没空再研究这个程序了,嗯,还是觉得WP挺好的。

About this Entry

This page contains a single entry by SOTHINK published on April 3, 2010 7:51 PM.

YouTube、Blogger和Picasa都可以访问了? was the previous entry in this blog.

Adobe CS5 激活方法 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.