diff --git a/app/index/controller/TopicNas.php b/app/index/controller/TopicNas.php index 1088e179..a4bedd0b 100644 --- a/app/index/controller/TopicNas.php +++ b/app/index/controller/TopicNas.php @@ -347,7 +347,10 @@ class TopicNas extends Common $parent_two = ArticleCategoryModel::ParentChild(array_column($categorys, 'id'))->language($this->lang_id)->column('pid','id');//二级分类id $articles_data = $articles->toArray(); foreach ($articles_data as &$v) { - $v['pid'] = isset($parent_two[$v['category_id']])?$parent_two[$v['category_id']]:''; + if ( isset($parent_two[$v['category_id']]) ) { + $v['pid'] = $v['category_id']; + $v['category_id'] = $parent_two[$v['category_id']]; + } } return success('success', $articles_data);