This commit is contained in:
joyqi 2017-08-09 14:10:41 +08:00
parent eb68b52800
commit 41751a3625
2 changed files with 26 additions and 3 deletions

View File

@ -646,7 +646,7 @@ class Widget_Abstract_Contents extends Widget_Abstract
if (!empty($value['categories'])) {
$value['category'] = $value['categories'][0]['slug'];
$value['directory'] = $this->widget('Widget_Metas_Category_List')->getAllParents($value['categories'][0]['mid']);
$value['directory'] = $this->widget('Widget_Metas_Category_List')->getAllParentsSlug($value['categories'][0]['mid']);
$value['directory'][] = $value['category'];
}
@ -899,7 +899,10 @@ class Widget_Abstract_Contents extends Widget_Abstract
*/
public function directory($split = '/', $link = true, $default = NULL)
{
$directory = $this->directory;
$category = $this->categories[0];
$directory = $this->widget('Widget_Metas_Category_List')->getAllParents($category['mid']);
$directory[] = $category;
if ($directory) {
$result = array();

View File

@ -323,7 +323,7 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
*/
public function filter(array $value)
{
$value['directory'] = $this->getAllParents($value['mid']);
$value['directory'] = $this->getAllParentsSlug($value['mid']);
$value['directory'][] = $value['slug'];
$tmpCategoryTree = $value['directory'];
@ -358,6 +358,26 @@ class Widget_Metas_Category_List extends Widget_Abstract_Metas
{
$parents = array();
if (isset($this->_parents[$mid])) {
foreach ($this->_parents[$mid] as $parent) {
$parents[] = $this->_map[$parent];
}
}
return $parents;
}
/**
* 获取某个分类所有父级节点缩略名
*
* @param mixed $mid
* @access public
* @return array
*/
public function getAllParentsSlug($mid)
{
$parents = array();
if (isset($this->_parents[$mid])) {
foreach ($this->_parents[$mid] as $parent) {
$parents[] = $this->_map[$parent]['slug'];