公共hook global_footerjavascript
模板顯示形式: $_G['setting']['pluginhooks']['global_footer']java
追蹤jquery
runhooks();cookie
↓ ui
if($_G['setting']['plugins'][HOOKTYPE.'_common']) { hookscript('common', 'global', 'funcs', array(), 'common'); }
↓this
插件類中相對應的方法spa
//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']code
追蹤blog
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(); } }