本实例版本为ThinkCMF 5.0.190111 正式版。
修改/app/portal/service/ApiService.php下的tagArticles()方法,部分代码片段修改前后:
if (empty($tagId)) { return null; }else { // $field = !empty($param['field']) ? $param['field'] : 'post.*'; $field = !empty($param['field']) ? $param['field'] : 'post.*,category_post.category_id as category_id'; //array_push($join, ['__PORTAL_TAG_POST__ tag_post', 'post.id = tag_post.post_id']); array_push($join, ['__PORTAL_TAG_POST__ tag_post', 'post.id = tag_post.post_id'],['__PORTAL_CATEGORY_POST__ category_post', 'post.id = category_post.post_id']);//by hihelp $where['tag_post.tag_id'] = $tagId; }
然后找到
$articles = $portalPostModel->alias('post')->field($field)
修改为:
$articles = $portalPostModel->alias('post')->group('post.id')->field($field)
group('post.id')去重。