|
|
在线手册:http://faq.comsenz.com/library/plug/plugin/plugin_pre.htm
嵌入点类型
1、页面嵌入点(作用:修改页面显示)
2、信息提示嵌入点(作用:修改showmessage())
3、广告嵌入点(作用:处理广告位数据)
4、功能嵌入点(作用:处理主题,帖子,头像等)
页面嵌入点的三种类型
1、全局页面嵌入点(运行位置:公共模板页面,如头部,尾部)
2、普通页面嵌入点(运行位置:普通模块模板页面)
3、输出前置页面嵌入点(运行位置:模块与模板间(模块输出之后,页面载入之前),处理数据)
页面嵌入点类的命名规则
全局页面嵌入点类(必须)
class plugin_插件标识符{}
如:plugin_thi_kf{}
普通嵌入点类
class plugin_插件标识符_入口文件名 extends 全局页面嵌入点类{} 必须继承全局页面嵌入点类
如:class plugin_thi_kf_forum extends plugin_thi_kf{}
如:forum.php?mod=viewthread&tid=1 中的forum就是入口文件名
页面嵌入点方法命名规则
全局页面嵌入点方法
function global_任意(){}
输出前置页面嵌入点方法
function 模块名_任意_output(){}
普通页面嵌入点方法
function 模块名_任意(){}
如:forum.php?mod=viewthread&tid=1(viewthread就是模块名 mod后面跟着的就是模块名)
全局嵌入点方法写在全局嵌入点类中
普通嵌入点方法写在普通嵌入点类中
普通嵌入点类要继承全局嵌入点类
例子:
- <?php
- /*全局嵌入点类(公共嵌入点类) class plugin_插件标识符{}*/
- class plugin_thi_kf{
- /*全局嵌入点方法 function global_任意(){}*/
- function global_cpnav_extral1() {
- return 'hellow discuz';
- }
- }
- /*普通嵌入点类(脚本嵌入点类) class plugin_插件标识符_入口文件名 extends 全局页面嵌入点类{}*/
- class plugin_thi_kf_forum extends plugin_thi_kf {
- /*普通嵌入点方法 function 模块名_任意(){}*/
- function index_status_extra() {
- return 'wellcome to php4';
- }
- /*输出前置页面嵌入点方法 function 模块名_任意_output(){}*/
- function index_thirteen_output() {
- global $_G;
- $_G['member']['username'] = 'hehe';
- }
- }
- ?>
复制代码 页面嵌入点的两种返回值类型
字符串类型
示例:[string global_login_extra]
作用:普通数据显示
数据类型:列表数据显示
示例:[array forumdisplay_thread_subject/0] (0 是数组的键名)
作用:列表数据显示
例子:
- function forumdisplay_thread_subject() {
- return array(
- 0 => '第一个主题',
- 1 => '第二个主题',
- )
- }
复制代码
插件模板的定义规则
用法:
include template(插件标识符:模板目录名称/模板名称)
示例:include template ('thi_kf:forum/thirteen');
对应
插件目录/thi_kf/template/forum/thirteen.htm
例子(插件文件中):
- <?php
- /*全局嵌入点类 class plugin_插件标识符{}*/
- class plugin_thi_kf{
- /*全局嵌入点方法 function global_任意(){}*/
- function global_cpnav_extral1() {
- /*include template(插件标识符:模板目录名称/模板名称)*/
- include template('thi_kf:forum/thiteen')
- }
- }
- /*普通嵌入点类 class plugin_插件标识符_入口文件名 extends 全局页面嵌入点类{}*/
- class plugin_thi_kf_forum extends plugin_thi_kf {
- /*普通嵌入点方法 function 模块名_任意(){}*/
- function index_status_extra() {
- return 'wellcome to php4';
- }
- /*输出前置页面嵌入点方法 function 模块名_任意_output(){}*/
- function index_thirteen_output() {
- global $_G;
- $_G['member']['username'] = 'hehe';
- }
- }
- ?>
复制代码 block 标签的应用
作用:将显示的内容,存储到指定变量中
示例:
<!--block 变量名-->
任意的html内容
<!--/block-->
然后在模板文件中写:
- <!--{block str}-->
- <span>欢迎来到php4中文网,请记住我们的网址为:www.php4.cn</span>
- <!--{/block}-->
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|