关于前端钩子 按钮显示的问题 大佬们帮我看看 哪个地方有有问题
关于前端钩子 按钮显示的问题 大佬们帮我看看 哪个地方有问题最终想显示的是
发帖框顶部 发帖框中部 发帖框底部 还有 帖子和列表页的快速回复区域显示
xml文件里面的代码
[*]<item id="hooks">
[*] <item id="post_top">
[*] <item id="qier_thread_top"><!]></item>
[*] </item>
[*] <item id="post_middle">
[*] <item id="qier_thread_middle"><!]></item>
[*] </item>
[*] <item id="post_bottom">
[*] <item id="qier_thread_button"><!]></item>
[*] </item>
[*] <item id="viewthread_fastpost_content">
[*] <item id="qier_thread_viewthread_fastpost_content"><!]></item>
[*] </item>
[*] <item id="forumdisplay_postbutton_bottom">
[*] <item id="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="stylesheet" type="text/css" href="' . $css_url . '" />';
[*] $output .= '<script type="text/javascript" src="' . $js_url . '"></script>';
[*]
[*] $button = '<button type="button" id="qier_thread_button" class="qier-thread-button">';
[*] $button .= '<span class="qier-thread-icon"></span>';
[*] $button .= '<span class="qier-thread-text">' . $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
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页:
[1]