第一范文网 - 专业文章范例文档资料分享平台

DiscuzX3.x模板插件开发制作教程(从入门到精通)

来源:用户分享 时间:2025/6/15 5:21:34 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

function HookId_2() { ......

return ...; }

......}?>

??plugin_

??普通版脚本中的类名以 plugin_ 开头。手机版脚本中的类名以 mobileplugin_ 开头。

??identifier

??插件的唯一标识符,在插件设置中设置。 ??CURSCRIPT

??嵌入点位于的脚本名,如 forum.php 为 forum。

??HookId

函数名

调用位置

所有模块执行前被调用

声明位置

参数含义

HookId() 脚本嵌入点类

$value: array('template' => 当前要输出的模版,'message' => showmessage 的信息内容,'values' => showmessage 的信息

脚本嵌入点类

变量,

)

全局嵌入点类 脚本嵌入点类

$value: array('param' => showmessage() 函数的参数数组, )

HookId_output($value) 模块执行完毕,模板输出前被调用

global_HookId() 模块执行完毕,模板输出前被调用 showmessage() 执行时调用

HookId_message($value)

ad_adId($value)

相应的广告位中调用 $value: array('params' => 广告位参数,'content' => 当前广

全局嵌入点类

函数名为广告位脚本 ID 如:告位原本将要显示的内容,

脚本嵌入点类

ad_headerbanner() )

common() 所有模块执行前被调用 全局嵌入点类

$value: array('param' => caller 函数的参数数组,'caller' => caller 函数,此嵌入点被哪个函数调用'discuzcode' 被 discuzcode() 调用'messagecutstr' 被 messagecutstr() 调用 )

discuzcode($value)

discuzcode() 函数执行时调用

用于在帖子内容解析时嵌入自己的功能,函数

全局嵌入点类

中 $_G['discuzcodemessage'] 变量为待解析的字串

deletethread($value)

deletethread() 函数执行时调用

用于在主题删除前后嵌入自己的功能,此函数$value: array('param' => deletethread() 函数的参数数将在 deletethread() 中被调用 2 次,函数中 全局嵌入点类 组,'step' => 删除的步骤'check' 检测步骤'delete' 删除步骤 $_G['deletethreadtids'] 变量为待处理的 TID ) 数组

deletepost() 函数执行时调用

用于在帖子删除前后嵌入自己的功能,此函数$value: array('param' => deletepost() 函数的参数数组,'step' 将在 deletepost() 中被调用 2 次,函数中 全局嵌入点类 => 删除的步骤'check' 检测步骤'delete' 删除步骤 $_G['deletepostids'] 变量为待处理的 ID 数) 组

avatar() 函数执行时调用

$value: array('param' => avatar() 函数的参数数组

用于在头像调用时嵌入自己的功能,函数中 全局嵌入点类

)

$_G['hookavatar'] 变量为新头像返回值

$start,

贴内用户信息标记,返回值为标记显示内容

$post: 当前帖子信息数组

全局嵌入点类 $start: 用户填写的前置字符

$end: 用户填写的后置字符

deletepost($value)

avatar($value) (X2.5 新增) profile_node($post, $end)

(X3.0 新增)

要查看所有的预定义嵌入点,请打开 config/config_global.php 文件,将文件结尾添加的设计者模式值改成“2”,然后更新缓存即可。在页面源码中查找\可搜索到嵌入点。(详细内容可参阅的《插件嵌入点列表》)

$_config['plugindeveloper'] = 2;

预定义的嵌入点会在页面预置好的位置输出函数返回的内容。函数返回值类型如果是 array 且是空值的,必须输出一个空数组,如: return array();

函数名并不限于以上列表,您可以自定义,只要符合以下规则,函数就会在适当的地方被调用。

function CURMODULE_USERDEFINE[_output]() CURMODULE 指明了此函数在哪个模块执行,可通过常量 CURMODULE 得到当前页面的 CURMODULE 值。 USERDEFINE 可自定义,如果函数名以“_output”

结尾则会在模板输出前调用,否则会在模块执行前调用。 如:attachment_test() 函数会在论坛的下载附件的时候执行。 “_output”结尾的函数的第一个参数为数组,含义为 array('template' => 要输出的模板名, 'message' => showmessage 的文字) 如:以下函数将在登录的时候输出调试文字 function logging_test_output($a) { print_r($a);

print_r($_POST);}

plugin_identifier 类中的其它函数为了便于阅读建议以“_”开头,如:

function _updatecache() { ......

return ...;

}}class plugin_sample_forum extends plugin_sample { function viewthread_posttop() { ......

return ...; }

......}?>

插件嵌入点列表 · 全局(common/)

extcredits.htm

string spacecp_credit_extra faq.htm string faq_extra footer.htm string global_footer

string global_footerlink header.htm string global_cpnav_top (X2.5) string global_cpnav_extra1 string global_cpnav_extra2 string global_qmenu_top (X3) string global_qmenu_bottom (X3) string global_nav_extra (X2.5)

string global_header userabout.htm array global_userabout_top string userapp_menu_top string userapp_menu_middle

array global_userabout_bottom userstatus.htm string global_usernav_extra1 string global_usernav_extra2 string global_usernav_extra3

string global_usernav_extra4 (X2.5) · 论坛(forum/)

collection_all.htm (X2.5)

string collection_index_top

string collection_index_bottom collection_comment.htm (X2.5) string collection_nav_extra collection_index.htm (X2.5) string collection_index_top

string collection_index_bottom collection_mycollection.htm (X2.5) string collection_index_top

string collection_index_bottom collection_nav.htm (X2.5) string collection_nav_extra collection_view.htm (X2.5) string collection_viewoptions string collection_view_top

string collection_threadlistbottom string collection_relatedop string collection_view_bottom

string collection_side_bottom discuz.htm string index_status_extra string index_nav_extra (X2.5) string index_top

string index_catlist_top (X2.5)

array index_followcollection_extra (X3) array index_favforum_extra (X2.5)

DiscuzX3.x模板插件开发制作教程(从入门到精通).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c0u3t49tq0j2r4yi9c250_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top