• discuz hook使用


    公共hook  global_footer

    模板显示形式: $_G['setting']['pluginhooks']['global_footer']

    追踪

    runhooks();

    ↓ 

    if($_G['setting']['plugins'][HOOKTYPE.'_common']) {
                hookscript('common', 'global', 'funcs', array(), 'common'); 
            }

    插件类中相对应的方法

    //plugin_qqconnect == plugin_qqconnect_common    
    class
    plugin_qqconnect extends plugin_qqconnect_base { var $allow = false; function plugin_qqconnect() { $this->init(); } function common() { $this->common_base(); } function global_footer() { if(!$this->allow) { return; } global $_G; if(!$_G['cookie']['client_token'] || !empty($_G['inshowmessage']) || empty($_G['cookie']['connect_js_name'])) { return; } if($_G['cookie']['connect_js_name'] == 'user_bind') { require_once libfile('function/connect'); $params = array('openid' => $_G['cookie']['connect_uin']); return connect_user_bind_js($params); }elseif($_G['cookie']['connect_js_name'] == 'feed_resend') { require_once libfile('function/connect'); return connect_feed_resend_js(); } } }

    模块动作 hook 

    模板显示形式:  $_G['setting']['pluginhooks']['logging_method']

    追踪

    runhooks();

    hookscript(CURMODULE, $_G['basescript']);// 如CURMODULE :logging   $_G['basescript']: member

    插件类中相对应的方法

    class plugin_qqconnect_member extends plugin_qqconnect {
    
        function logging_method() {// CURMODULE...
            if(!$this->allow) {
                return;
            }
            return tpl_login_bar();
        }
    }

    手动添加一个公共的hook

    在专题中添加一个hook

    <!--{hook/global_topic_show}-->

    在插件类common类(即没有basescript类)中添加方法 global_topic_show(begin with global_...)

    如:

    class plugin_rotate_award extends plugin_rotate_award_base {
    
        var $allow = false;
    
        function plugin_rotate_award() {
            $this->init();
        }
    
        function common() {
            $this->common_base();
        }
    
        //抽奖转盘
        function global_rotate_reward() {
            global $_G;
            if (!$this->allow) {
                return;
            }
            $extrastr = '';
            if (!$_G['pluginrotateaward']['loadedjquery']) {
                $extrastr = '<script type="text/javascript" src="source/plugin/rotate_award/template/jquery-1.7.2.min.js"></script><script type="text/javascript">jQuery.noConflict();</script>';
            }
            return $extrastr. tpl_rotate_reward();
        }
    
    }
  • 相关阅读:
    P1121 环状最大两段子段和
    无题
    cdoj 1485 柱爷搞子串 sam treap
    自然数幂和
    Gym 100341C AVL Trees NTT
    线性筛分解质因子
    codeforces 366 Ant Man dp
    UVALive 6914 Maze Mayhem 轮廓线dp
    hdu 5790 Prefix 字典树 主席树
    莫比乌斯反演个人小结
  • 原文地址:https://www.cnblogs.com/bandbandme/p/3299101.html
Copyright © 2020-2023  润新知