我正在尝试在Joomla 3.x的控制器中注册自定义任务,因此我正在修改构造函数(就像1.5 / 2.5中一样),使用以下代码:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
class jjemailControllerjjemail extends JControllerLegacy
{
/**
* constructor (registers additional tasks to methods)
* @return void
*/
public function __construct($config = array())
{
parent::__construct($config);
// Register Extra tasks
$this->registerTask('email, 'email');
}
public function email()
{
$this->setRedirect('index.php?option=com_jjemail&view=thanks', $msg);
}
}
现在,如果我在任务注册之前的构造函数中添加一个var dump,则会显示,但在email()函数中添加一个var dump却什么也没有显示。所以我猜我在某个地方注册任务失败了。
调用此路由看起来像:
JRoute::_('index.php?option = com_jjemail&task = jjemail.email');
有人有任何想法,为什么我会以这种愚蠢的方式失败吗?
$this->registerTask('email, 'email');
在第一个 "email" 后面缺少一个单引号。 - Erenor Paz