循环首页(index.php)文章列表
<?php while($this->next()): ?>
<!--文章标题-->
<?php $this->title() ?>
<?php endwhile; ?>
其它示例代码
使用Widget_Metas_Category_List
即可列出所有分类。
$obj = $this->widget('Widget_Metas_Category_List');
if($obj->have()){
while($obj->next()){
$obj->name();
... ...
}
}else{
echo '无分类';
}
可用字段
字段名 | 描述 |
mid | 分类id |
name | 分类名称 |
slug | 分类缩写名 |
type | 分类类型,譬如categorery |
description | 分类的描述 |
count | 该分类下的文章数目 |
order | xxx |
parent | 父分类的mid |
levels | 所在的层级 |
directory | Array类型,数组元素是每层分类的slug |
permalink | 该分类的url |
feedUrl | 该分类的feed地址 |
feedRssUrl | 该分类的feedRss地址 |
feedAtomUrl | 该分类的feedAtom地址 |
可用参数
- ignore 不显示的分类mid
- current 当前分类mid,如果设置了,则会在输出是增加class=”category-active”样式,
$this->widget('Widget_Metas_Category_List','ignore=1¤t=2')
,则不显示mid为1的分类,并在mid为2的li上增加“category-active”类型
常见用法
通过widget方法初始化组件,并使用next()进行迭代。
常规用法
$this->widget('Widget_Metas_Category_List')->to($recent);
while($recent->next()):
......
endwhile;
快捷用法
通过parse方法,简化上述
$this->widget('Widget_Metas_Category_List')->parse('<a href="{permalink}">{name}(count)</a>');