您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何在同一个插件中添加多个action?

2024/2/21 18:35:21发布18次查看
比如我有个插件,叫做test
class test_plugin implements typecho_plugin_interface { public static function activate() { helper::addaction('test', 'test_action'); //action.php helper::addaction('custom', 'custom_action'); //custom.php } ... .. .}

我想添加两个action,分别是test和custom。。
这样写,访问action/test是正常的,但是访问action/custom却报错,说找不到。
请问能不能在一个插件中添加两个action?如果可以,要怎么写代码?
回复内容: 比如我有个插件,叫做test
class test_plugin implements typecho_plugin_interface { public static function activate() { helper::addaction('test', 'test_action'); //action.php helper::addaction('custom', 'custom_action'); //custom.php } ... .. .}

我想添加两个action,分别是test和custom。。
这样写,访问action/test是正常的,但是访问action/custom却报错,说找不到。
请问能不能在一个插件中添加两个action?如果可以,要怎么写代码?
widget/do.php代码
if (isset($widgetname) && class_exists($widgetname)) { $reflectionwidget = new reflectionclass($widgetname); if ($reflectionwidget->implementsinterface('widget_interface_do')) { $this->widget($widgetname)->action(); return; }}
确实不可以,custom_action的文件include路径是custom/action.php,并且类名为custom_action
一个action就能够处理所有事情吧,如果需要增加action的话根据action的访问原理,你只能新增加一个plugins来定义它
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product