多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
钩子 === 在模版文件中经常看到调用钩子的用法 如: ```html <!--{hook/global_usernav_extra2}--> ``` 这行代码在模版解析文件中会如此解析: ```php $template = preg_replace("/\{hook\/(\w+?)(\s+(.+?))?\}/ie", "\$this->hooktags('\\1', '\\3')", $template); ``` 可以看到是直接调用$this->hooktags方法,那hooktags是怎么定义的呢?请看: ```php function hooktags($hookid, $key = '') { global $_G; $i = count($this->replacecode['search']); $this->replacecode['search'][$i] = $search = "<!--HOOK_TAG_$i-->"; $dev = ''; if(isset($_G['config']['plugindeveloper']) && $_G['config']['plugindeveloper'] == 2) { $dev = "echo '<hook>[".($key ? 'array' : 'string')." $hookid".($key ? '/\'.'.$key.'.\'' : '')."]</hook>';"; } $key = $key !== '' ? "[$key]" : ''; $this->replacecode['replace'][$i] = "<?php {$dev}if(!empty(\$_G['setting']['pluginhooks']['$hookid']$key)) echo \$_G['setting']['pluginhooks']['$hookid']$key;?>"; return $search; } ```