post页面用于展示单片文章。由于post.php和archive.php都是由Widget_Archive加载,因此其api都是一样的。唯一不同的地方就是,archive.php页面中,Widget_Archive的栈中可能有多篇文章,而post页面中,则只有一篇。
这里也列出post中常用的一些api
$this->permalink() 输出文章的链接
$this->title() 输出文章标题
$this->category() 输出分类信息。参数表示分隔符。
$this->content() 输出文章内容
$this->expect(200) 输出文章摘要,参数200表示输出文章的前200字符
$this->author() 输出作者名称
$this->author->permalink() 输出作者的链接
另外,post页面相对于index或者archive页面,一般还会有“标签”和“评论”模块。
标签
tags(',', true, 'none'); ?>
获取当前单篇文章的标签,用“,”符号隔开。
评论
调用comments页面片:
need('comments.php'); ?>
其中,comments页面片内容可能如下:
commentsNum(); ?>
- comments()->to($comments); ?> next()): ?>
content(); ?>
更详细的comments页面片用法和api,请参考《comments页面》一文
上一篇、下一篇
post页面中,往往加上上一篇、下一篇链接,可以极大方便用户阅读,并且有利于增加网站pv。其调用方法很简单,代码如下:
或者
输出文章的云标签
$this->widget('Widget_Metas_Tag_Cloud','ignoreZeroCount=1&limit=20')->to($tags);
$tags->parse('{name}');
author(); ?>