返回列表 发帖
查看: 1070|回复: 2

[已处理] X3.5的默认门户模板有个小BUG

41

主题

110

回帖

172

积分

渐入佳境

贡献
1 点
金币
5 个
发表于 2022-12-6 15:28:51 | 显示全部楼层 |阅读模式
未启用生效的门户分类会在任意门户栏目中右侧相关分类里显示,无法隐藏,这个需要怎么改才能去掉不显示呢
1 贡献

最佳答案

https://gitee.com/Discuz/DiscuzX/pulls/1826
打开
source/function/function_portal.php

找到
  1. function category_remake($catid) {
  2.         global $_G;

  3.         $cat = $_G['cache']['portalcategory'][$catid];
  4.         if(empty($cat)) return array();

  5.         foreach ($_G['cache']['portalcategory'] as $value) {
  6.                 if($value['catid'] == $cat['upid']) {
  7.                         $cat['ups'][$value['catid']] = $value;
  8.                         $upid = $value['catid'];
  9.                         while(!empty($upid)) {
  10.                                 if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
  11.                                         $upid = $_G['cache']['portalcategory'][$upid]['upid'];
  12.                                         $cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
  13.                                 } else {
  14.                                         $upid = 0;
  15.                                 }
  16.                         }
  17.                 } elseif($value['upid'] == $cat['catid']) {
  18.                         $cat['subs'][$value['catid']] = $value;
  19.                 } elseif($value['upid'] == $cat['upid']) {
  20.                         $cat['others'][$value['catid']] = $value;
  21.                 }
  22.         }
  23.         if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
  24.         return $cat;
  25. }
复制代码
替换为
  1. function category_remake($catid) {
  2.         global $_G;

  3.         $cat = $_G['cache']['portalcategory'][$catid];
  4.         if(empty($cat)) return array();
  5.         require_once libfile('function/portalcp');
  6.         $categoryperm = getallowcategory($_G['uid']);
  7.         foreach ($_G['cache']['portalcategory'] as $value) {
  8.                 if($value['catid'] == $cat['upid']) {
  9.                         $cat['ups'][$value['catid']] = $value;
  10.                         $upid = $value['catid'];
  11.                         while(!empty($upid)) {
  12.                                 if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
  13.                                         $upid = $_G['cache']['portalcategory'][$upid]['upid'];
  14.                                         $cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
  15.                                 } else {
  16.                                         $upid = 0;
  17.                                 }
  18.                         }
  19.                 } elseif($value['upid'] == $cat['catid']) {
  20.                         $cat['subs'][$value['catid']] = $value;
  21.                 } elseif($value['upid'] == $cat['upid']) {
  22.                         if (!$value['closed'] || $_G['group']['allowdiy'] || $categoryperm[$value['catid']]['allowmanage']) {
  23.                                 $cat['others'][$value['catid']] = $value;
  24.                         }
  25.                 }
  26.         }
  27.         if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
  28.         return $cat;
  29. }
复制代码
修改后,没权限的用户,不会显示未启用的分类

回复

使用道具 举报

17

主题

568

回帖

1816

积分

应用开发者

贡献
63 点
金币
902 个
QQ
发表于 2022-12-6 15:51:36 | 显示全部楼层
https://gitee.com/Discuz/DiscuzX/pulls/1826
打开
source/function/function_portal.php

找到
  1. function category_remake($catid) {
  2.         global $_G;

  3.         $cat = $_G['cache']['portalcategory'][$catid];
  4.         if(empty($cat)) return array();

  5.         foreach ($_G['cache']['portalcategory'] as $value) {
  6.                 if($value['catid'] == $cat['upid']) {
  7.                         $cat['ups'][$value['catid']] = $value;
  8.                         $upid = $value['catid'];
  9.                         while(!empty($upid)) {
  10.                                 if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
  11.                                         $upid = $_G['cache']['portalcategory'][$upid]['upid'];
  12.                                         $cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
  13.                                 } else {
  14.                                         $upid = 0;
  15.                                 }
  16.                         }
  17.                 } elseif($value['upid'] == $cat['catid']) {
  18.                         $cat['subs'][$value['catid']] = $value;
  19.                 } elseif($value['upid'] == $cat['upid']) {
  20.                         $cat['others'][$value['catid']] = $value;
  21.                 }
  22.         }
  23.         if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
  24.         return $cat;
  25. }
复制代码
替换为
  1. function category_remake($catid) {
  2.         global $_G;

  3.         $cat = $_G['cache']['portalcategory'][$catid];
  4.         if(empty($cat)) return array();
  5.         require_once libfile('function/portalcp');
  6.         $categoryperm = getallowcategory($_G['uid']);
  7.         foreach ($_G['cache']['portalcategory'] as $value) {
  8.                 if($value['catid'] == $cat['upid']) {
  9.                         $cat['ups'][$value['catid']] = $value;
  10.                         $upid = $value['catid'];
  11.                         while(!empty($upid)) {
  12.                                 if(!empty($_G['cache']['portalcategory'][$upid]['upid'])) {
  13.                                         $upid = $_G['cache']['portalcategory'][$upid]['upid'];
  14.                                         $cat['ups'][$upid] = $_G['cache']['portalcategory'][$upid];
  15.                                 } else {
  16.                                         $upid = 0;
  17.                                 }
  18.                         }
  19.                 } elseif($value['upid'] == $cat['catid']) {
  20.                         $cat['subs'][$value['catid']] = $value;
  21.                 } elseif($value['upid'] == $cat['upid']) {
  22.                         if (!$value['closed'] || $_G['group']['allowdiy'] || $categoryperm[$value['catid']]['allowmanage']) {
  23.                                 $cat['others'][$value['catid']] = $value;
  24.                         }
  25.                 }
  26.         }
  27.         if(!empty($cat['ups'])) $cat['ups'] = array_reverse($cat['ups'], TRUE);
  28.         return $cat;
  29. }
复制代码
修改后,没权限的用户,不会显示未启用的分类

谢谢了,我去改下 
发表于 2022-12-6 16:06
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2024-5-8 10:00 , Processed in 0.035062 second(s), 9 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2024 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表