Joomla调用函数
Joomla call function
我有一个 joomla3 站点,想从 joomla 模板中的插件调用函数。为此,我在模板中编写了这段代码 <?php echo my_function($id);?>
.
在插件中 class 我有
class plgSystemMyPlugin extends JPlugin {...}
function my_function($id) { echo $id; }
但是当我刷新页面时,我得到
Failed to load resource: the server responded with a status of 500
(Internal Server Error)
有什么问题,有人可以帮我吗?
你好玛丽娜,
您应该按照以下方式在您的 Joomla!模板 index.php :
JPluginHelper::importPlugin( 'system' );
$dispatcher = JEventDispatcher::getInstance();
$result = $dispatcher->trigger('MySpecificEvent', $arguments);
<?php echo $result;?>
并在您创建的系统插件中,
class plgSystemMyPlugin extends JPlugin {
public function MySpecificEvent($id){
echo $id;
}
}
告诉我它是否适合你。
谢谢
我有一个 joomla3 站点,想从 joomla 模板中的插件调用函数。为此,我在模板中编写了这段代码 <?php echo my_function($id);?>
.
在插件中 class 我有
class plgSystemMyPlugin extends JPlugin {...}
function my_function($id) { echo $id; }
但是当我刷新页面时,我得到
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
有什么问题,有人可以帮我吗?
你好玛丽娜,
您应该按照以下方式在您的 Joomla!模板 index.php :
JPluginHelper::importPlugin( 'system' );
$dispatcher = JEventDispatcher::getInstance();
$result = $dispatcher->trigger('MySpecificEvent', $arguments);
<?php echo $result;?>
并在您创建的系统插件中,
class plgSystemMyPlugin extends JPlugin {
public function MySpecificEvent($id){
echo $id;
}
}
告诉我它是否适合你。
谢谢