新增 $this->directory() 方法,用来方便地输出多级分类

ref #597
This commit is contained in:
joyqi 2017-08-09 12:52:31 +08:00
parent 24cc1f5a5e
commit eb68b52800

View File

@ -888,6 +888,32 @@ class Widget_Abstract_Contents extends Widget_Abstract
}
}
/**
* 输出文章多级分类
*
* @access public
* @param string $split 多个分类之间分隔符
* @param boolean $link 是否输出链接
* @param string $default 如果没有则输出
* @return void
*/
public function directory($split = '/', $link = true, $default = NULL)
{
$directory = $this->directory;
if ($directory) {
$result = array();
foreach ($directory as $category) {
$result[] = $link ? '<a href="' . $category['permalink'] . '">'
. $category['name'] . '</a>' : $category['name'];
}
echo implode($split, $result);
} else {
echo $default;
}
}
/**
* 输出文章标签
*