🎅挂件馆🌟铭牌馆✨️靓标库🧚‍♂️名人堂🦄宝可梦🍎水果机🥊猜拳🏧黑市🏧银行💹抽奖
   🎁
返回列表 发布新帖
查看: 558|回复: 2

[代码技巧] 解决社区名人堂/荣誉榜插件的用户资料页钩子挂载显示问题

[复制链接]
飞流 00001
起源之星
任务·年会员
累计签到LV.3
摩羯座
+2
社区贡献
346 223 25271
等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 145 颗
   贡献 : 25479 点
   金币 : 4 枚
Icon在线时间 : 1993 小时
Icon注册时间 : 2024-11-22
Icon最后登录 : 2026-10-12
送礼物:3 个 收礼物:1 个
FLLTCN 实名认证 特邀大神 诚信商家 信誉担保 精华作者+ 官方团队 vip vip-year 发表于 2025-9-28 17:21:02 | 查看全部 |阅读模式 浙江金华

交易无需等待,成交就是现在,全面资源整合网络大咖云集,让你轻松玩转互联网!

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我在六月份时候开始使用这个功能插件,早先就发现了这个问题,也没有深入研究,现在终于解决了,下面记录一下解决方法。
首先我们定位问题文件/source/plugin/viewui_famous/hook.class.php(此为插件PC钩子文件)
搜索关键词space_profile_baseinfo_top_output
image.webp
我们替换为优化后的代码
  1. public function space_profile_baseinfo_middle_output(){
  2.     global $_G;
  3.     $output = '';
  4.    
  5.     // 获取当前访问的目标用户ID
  6.     $targetUid = intval($_GET['uid']);
  7.     if(empty($targetUid)){
  8.         return $output; // 用户ID为空,返回空
  9.     }
  10.    
  11.     // 关键:查询目标用户的用户组ID
  12.     $targetGroupId = DB::result_first(
  13.         "SELECT groupid FROM %t WHERE uid = %d",
  14.         array('common_member', $targetUid)
  15.     );
  16.     if(empty($targetGroupId)){
  17.         return $output; // 无用户组信息,返回空
  18.     }
  19.    
  20.     // 查询该用户的名人堂荣誉
  21.     $honors = C::t('#viewui_famous#viewui_famous_people')->FetchPeopleHonors($targetUid);
  22.    
  23.     // 验证条件:用户组权限+是名人堂用户+有荣誉信息
  24.     if($this->CheckUse($targetGroupId) && $this->CheckFamous($targetUid) && !empty($honors)){
  25.         $output .= '<h2 class="mbn" style="color: red;">'.lang('plugin/viewui_famous', 'gethonortitle').'</h2><ul>';
  26.         foreach($honors as $honor){
  27.             // 拼接荣誉信息HTML(包含链接和描述)
  28.             $output .= '<li>';
  29.             $output .= '<a href="plugin.php?id=viewui_famous&type='.$honor['typeid'].'#viewui-famous-famouslist-'.$honor['honorid'].'">';
  30.             $output .= $honor['name'].lang('plugin/viewui_famous', 'doc').$honor['honorname'];
  31.             if(!empty($honor['summary'])){
  32.                 $output .= '<span style="color: #ff4800;">'.$honor['summary'].'</span>';
  33.             }
  34.             $output .= '</a></li>';
  35.         }
  36.         $output .= '</ul>';
  37.     }
  38.    
  39.     return $output;
  40. }
复制代码
我们继续搜索关键词space_profile_baseinfo_top_output
image.webp
替换为优化后的代码
  1. public function space_profile_baseinfo_top_output(){
  2.     global $_G;
  3.     $output = '';
  4.    
  5.     // 获取当前访问的目标用户ID(从URL参数中获取)
  6.     $targetUid = intval($_GET['uid']);
  7.     if(empty($targetUid)){
  8.         return $output; // 若用户ID为空,直接返回空
  9.     }
  10.    
  11.     // 关键:通过用户ID查询其对应的用户组ID(groupid)
  12.     $targetGroupId = DB::result_first(
  13.         "SELECT groupid FROM %t WHERE uid = %d",
  14.         array('common_member', $targetUid) // 查询Discuz用户表(common_member)
  15.     );
  16.     // 若查询不到用户组(如用户不存在),直接返回
  17.     if(empty($targetGroupId)){
  18.         return $output;
  19.     }
  20.    
  21.     // 验证条件:使用用户组ID调用CheckUse,同时验证是否为名人堂用户及功能是否启用
  22.     if($this->CheckUse($targetGroupId) && $this->CheckFamous($targetUid) && ($this->openUserNameColor || $this->openUserNameBlod || $this->openIcon)){
  23.         $script = '';
  24.         // 目标元素选择器:用户名称容器(.kmtit .kmname)
  25.         $targetSelector = 'document.querySelector(\'.kmtit .kmname\')';
  26.         
  27.         // 1. 设置字体加粗(如果启用)
  28.         if($this->openUserNameBlod){
  29.             $script .= 'var targetEl = '.$targetSelector.';';
  30.             $script .= 'if(targetEl) targetEl.style.fontWeight = \'800\';';
  31.         }
  32.         
  33.         // 2. 设置文字颜色/渐变(如果启用)
  34.         if($this->openUserNameColor){
  35.             $script .= 'var targetEl = '.$targetSelector.';';
  36.             $script .= 'if(targetEl){';
  37.             // 处理渐变色(若颜色值含linear-gradient)
  38.             if(strpos($this->userNameColor, 'linear-gradient') !== false){
  39.                 $script .= 'targetEl.style.background = \''.$this->userNameColor.'\';';
  40.                 $script .= 'targetEl.style.webkitBackgroundClip = \'text\';';
  41.                 $script .= 'targetEl.style.backgroundClip = \'text\';';
  42.                 $script .= 'targetEl.style.color = \'transparent\';';
  43.             }else{
  44.                 // 普通颜色直接设置color
  45.                 $script .= 'targetEl.style.color = \''.$this->userNameColor.'\';';
  46.             }
  47.             $script .= '}';
  48.         }
  49.         
  50.         // 3. 添加名人堂图标(如果启用)
  51.         if($this->openIcon){
  52.             $script .= 'var targetEl = '.$targetSelector.';';
  53.             $script .= 'if(targetEl){';
  54.             $script .= 'targetEl.innerHTML += \'<a href="plugin.php?id=viewui_famous&mod=my"></a>\';';
  55.             $script .= '}';
  56.         }
  57.         
  58.         $output .= '<script>'.$script.'</script>';
  59.     }
  60.    
  61.     return $output;
  62. }
复制代码
解释一下不加载钩子的原因及修复关键
  • 已修正 CheckUse 参数传递错误,确保传入用户组 ID 而非用户 ID
  • 由于我使用的是第三方模板,原代码依赖的 .vwmy和.hud 元素不存在,需将目标元素替换为自己的哦

最新官方回复 2025-09-29 01:45:04
路虽远,行则将至;事虽难,做则必成。
神评新秀
社区贡献
30 72 3044
等级头衔
Icon组别 : 管理员
Icon等级 :

积分成就
   钻石 : 30 颗
   贡献 : 8651 点
   金币 : 9 枚
Icon在线时间 : 269 小时
Icon注册时间 : 2025-5-6
Icon最后登录 : 2026-6-8
送礼物:0 个 收礼物:0 个
ChuanQi vip 发表于 2025-9-29 01:45:04 来自手机端 | 查看全部 浙江金华
宝藏主题,千万别火,我不想被别人看到!
资源创造价值,诚信连接交易。
无名の勋章
国庆节
注册一周年
社区贡献
59 287 6255
等级头衔
Icon组别 : 老兵
Icon等级 :

积分成就
   钻石 : 1 颗
   贡献 : 3684 点
   金币 : 0 枚
Icon在线时间 : 1105 小时
Icon注册时间 : 2024-12-15
Icon最后登录 : 2026-9-3
送礼物:0 个 收礼物:0 个
vip 发表于 2025-9-29 20:12:42 来自手机端 | 查看全部 湖南
难怪刚刚在天上没看见你呢,原来是下凡了!
资源创造价值,诚信连接交易。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

飞流广播+ 发布

07-23 18:52
飞流:这论坛到底有没有资本给我投资一下啊!
07-20 22:07
系统消息:飞流安卓客户端APP已上线,请在QQ群(123129)群文件内获取下载。
02-21 02:22
01-24 12:40
站内通告

📢 六月份后均不在线,请悉知

提供资源交易、信息共享、靓号交流、技术变现、学习问答、兴趣娱乐等全面服务。

1.丰富功能系统,扩展社区特色玩法,打造最好的互联网聚集圈子。

2.准确信息真实交易,安全快捷又方便,让虚拟交易面对面。

3. 天上不会掉馅饼,话术骗术迷人心,切勿脱离平台线下交易,被骗与平台无关!

4. 欺诈骗钱,违规违法将视情受到警告&禁言&封号甚至检举至👮🏻‍♀️处理!

官方Q群:1003810038钉推群:BAYR2383 站长QQ:3388700000

飞流论坛(FLLT.CN),一个专注于资源信息发布、虚拟网络交易、技术学习与娱乐社交的交流平台。
  • 钉钉新帖推送群
  • 官方交流QQ群
  • 站长唯一微信号

💥客户端|🧿小黑屋|📴手机页|飞流网 |网站地图

GMT+8, 2026-10-13 14:03 , Processed in 0.061592 second(s), 67 queries, MemCached On , Gzip On.

飞流论坛 HanAnalytics icp

Copyright © 2024-2026 飞流网 版权所有 All Rights Reserved. X3.5

快速回复 返回顶部 返回列表