文章上一篇与下一篇挪用代码:
<?php $this->thePrev(); ?> <?php $this->theNext(); ?>或许
<?php $this->thePrev('上一篇 : %s', '没有上一篇'); ?><?php $this->theNext('下一篇 : %s', '没有下一篇'); ?>如许的会输出同时文章的标题和链接,不是很利于加款式。
不过1.0版的typecho,已支撑更天真的上下文输出:$this->thePrev($format = '%s', $default = NULL, $custom = array('title' => '','tagClass' => ''));$custom 数组部份即为自定义内容,现在支撑给上下文链接增加自定义的 CSS 类名、及输出笔墨,笔墨部份支撑 html 代码:
$this->thePrev('%s', NULL, array('title' => '<span>上一篇</span>', 'tagClass' => 'prev-content'));上面的代码会输出:
<a class="prev-content" href="{permalink}" title="{title}"><span>上一篇</span></a>老版本(亲测:实在1.0版这么用也是能够的)
/*** 显现下一篇** @access public* @param string $default 假如没有下一篇,显现的默许笔墨* @return void*/function theNext($widget, $default = NULL){$db = Typecho_Db::get();$sql = $db->select()->from('table.contents')->where('table.contents.created > ?', $widget->created)->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', $widget->type)->where('table.contents.password IS NULL')->order('table.contents.created', Typecho_Db::SORT_ASC)->limit(1);$content = $db->fetchRow($sql); if ($content) {$content = $widget->filter($content);$link = '<a href="' . $content['permalink'] . '" title="' . $content['title'] . '">下一篇</a>';echo $link;} else {echo $default;}} /*** 显现上一篇** @access public* @param string $default 假如没有下一篇,显现的默许笔墨* @return void*/function thePrev($widget, $default = NULL){$db = Typecho_Db::get();$sql = $db->select()->from('table.contents')->where('table.contents.created < ?', $widget->created)->where('table.contents.status = ?', 'publish')->where('table.contents.type = ?', $widget->type)->where('table.contents.password IS NULL')->order('table.contents.created', Typecho_Db::SORT_DESC)->limit(1);$content = $db->fetchRow($sql); if ($content) {$content = $widget->filter($content);$link = '<a href="' . $content['permalink'] . '" title="' . $content['title'] . '">上一篇</a>';echo $link;} else {echo $default;}}挪用代码:
<?php thePrev($this); ?> 和 <?php theNext($this); ?>文章参考与http://t.160.me/33.html

评论列表