找回密码
 注册
查看: 1838|回复: 0

关于前端钩子 按钮显示的问题 大佬们帮我看看 哪个地方有有问题

[复制链接]

6

主题

0

回帖

174

积分

新生儿

积分
174
发表于 2024-9-8 00:35:24 来自手机 | 显示全部楼层 |阅读模式 来自:广东省广州市 电信
关于前端钩子 按钮显示的问题 大佬们帮我看看 哪个地方有问题

最终想显示的是
发帖框顶部 发帖框中部 发帖框底部 还有 帖子和列表页的  快速回复区域显示

xml文件里面的代码

  • <item id=&quot;hooks&quot;>
  •     <item id=&quot;post_top&quot;>
  •         <item id=&quot;qier_thread_top&quot;><![CDATA[qier_thread_post_top]]></item>
  •     </item>
  •     <item id=&quot;post_middle&quot;>
  •         <item id=&quot;qier_thread_middle&quot;><![CDATA[qier_thread_post_middle]]></item>
  •     </item>
  •     <item id=&quot;post_bottom&quot;>
  •         <item id=&quot;qier_thread_button&quot;><![CDATA[qier_thread_post_button]]></item>
  •     </item>
  •     <item id=&quot;viewthread_fastpost_content&quot;>
  •         <item id=&quot;qier_thread_viewthread_fastpost_content&quot;><![CDATA[qier_thread_viewthread_fastpost_content]]></item>
  •     </item>
  •     <item id=&quot;forumdisplay_postbutton_bottom&quot;>
  •         <item id=&quot;qier_thread_forumdisplay_postbutton_bottom&quot;><![CDATA[qier_thread_forumdisplay_postbutton_bottom]]></item>
  •     </item></item>
class.php里面的代码

  • <?php
  • if(!defined('IN_DISCUZ')) {
  •     exit('Access Denied');
  • }

  • class plugin_qier_thread {
  •     public function post_top() {
  •         if (!$this->is_plugin_enabled()) return '';
  •         return $this->qier_thread_button('post_top');
  •     }

  •     public function post_middle() {
  •         if (!$this->is_plugin_enabled()) return '';
  •         return $this->qier_thread_button('post_middle');
  •     }

  •     public function post_bottom() {
  •         if (!$this->is_plugin_enabled()) return '';
  •         return $this->qier_thread_button('post_bottom');
  •     }

  •     public function viewthread_fastpost_content() {
  •         if (!$this->is_plugin_enabled()) return '';
  •         global $_G;
  •         if($_G['cache']['plugin']['qier_thread']['show_in_fastpost']) {
  •             return $this->_get_button_html();
  •         }
  •         return '';
  •     }

  •     public function global_header() {
  •         if (!$this->is_plugin_enabled()) return;
  •         global $_G;
  •         $button_position = $this->get_button_position();
  •         $button_text = $_G['cache']['plugin']['qier_thread']['custom_button_text'] ?: lang('plugin/qier_thread', 'qier_thread_generate_article');
  •         
  •         // 只在发帖页面显示按钮
  •         if(CURSCRIPT == 'forum' && (CURMODULE == 'post' || CURMODULE == 'viewthread')) {
  •             include template('qier_thread:qier_thread_post');
  •         }
  •     }

  •     public function forumdisplay_postbutton_bottom() {
  •         if (!$this->is_plugin_enabled()) return '';
  •         global $_G;
  •         if($_G['cache']['plugin']['qier_thread']['show_in_fastpost']) {
  •             return $this->_get_button_html();
  •         }
  •         return '';
  •     }

  •     private function qier_thread_button($position) {
  •         global $_G;
  •         
  •         $enable = $_G['cache']['plugin']['qier_thread']['enable'];
  •         $button_position = $_G['cache']['plugin']['qier_thread']['button_position'];
  •         
  •         if (!$enable) {
  •             return '';
  •         }
  •         
  •         $position_map = [
  •             'post_top' => '1',
  •             'post_middle' => '2',
  •             'post_bottom' => '3'
  •         ];
  •         
  •         if ($button_position !== $position_map[$position]) {
  •             return '';
  •         }
  •         
  •         return $this->get_button_html();
  •     }

  •     private function _get_button_html() {
  •         global $_G;
  •         $button_text = $_G['cache']['plugin']['qier_thread']['custom_button_text'] ?: '这是个按钮';
  •         include template('qier_thread:button');
  •         return $return;
  •     }

  •     private function get_button_html() {
  •         $css_url = 'source/plugin/qier_thread/static/css/style.css';
  •         $js_url = 'source/plugin/qier_thread/static/js/qier_thread.js';
  •         
  •         $output = '<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;' . $css_url . '&quot; />';
  •         $output .= '<script type=&quot;text/javascript&quot; src=&quot;' . $js_url . '&quot;></script>';
  •         
  •         $button = '<button type=&quot;button&quot; id=&quot;qier_thread_button&quot; class=&quot;qier-thread-button&quot;>';
  •         $button .= '<span class=&quot;qier-thread-icon&quot;></span>';
  •         $button .= '<span class=&quot;qier-thread-text&quot;>' . $button_text . '</span>';
  •         $button .= '</button>';
  •         
  •         return $output . $button;
  •     }

  •     private function get_position_for_hook($hook) {
  •         switch ($hook) {
  •             case 'post_top': return 1;
  •             case 'post_middle': return 2;
  •             case 'post_bottom': return 3;
  •             default: return 0;
  •         }
  •     }

  •     public function get_button_position() {
  •         global $_G;
  •         return $_G['cache']['plugin']['qier_thread']['button_position'];
  •     }

  •     private function is_plugin_enabled() {
  •         global $_G;
  •         return !empty($_G['cache']['plugin']['qier_thread']['enable']);
  •     }}


试过好多方案  就是不能正常的显示出按钮 查看网页源代码 也没用相关插件的js或者css文件路径

也就是说没启动插件

不知道什么原因【上面的代码是改了好几种方案的其中一种了 都不显示】

日志全开  日志页抓不到。


来源:https://www.dismall.com/thread-23445-1-1.html
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

QQ|小黑屋|宝丽爱婴育儿网 ( 湘ICP备18010684号-1 )

GMT+8, 2026-3-2 11:33 , Processed in 0.089293 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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