我遇到joomla 3.5无法在子控制器中找到任务的问题。我正在运行J!转储,并且可以看到它正在运行子控制器的构造函数,但/administrator/index.php?option=com_mycomponent&task=subctrl.trask
返回task [trask] not found
我尝试使用$this->registerTask('trask', 'trask')
构造函数,但它没有帮助......对我做错的任何想法?
/administrator/components/com_mycomponent/controllers/subctrl.php
<?php
defined('_JEXEC') or die ;
class MycomponentControllerSubctrl extends JControllerAdmin
{
function __construct()
{
$this->registerTask('trask', 'trask');
dumpMessage('running controller');
dump($this, 'Ctrler');
}
public function trask()
{
dumpMessage('running Ctrl Trask');
return true;
}
}
我收到以下callstack:
# Function Location
1 JApplicationCms->execute() /Users/evanion/Projects/php/joomla/administrator/index.php:51
2 JApplicationAdministrator->doExecute() /Users/evanion/Projects/php/joomla/libraries/cms/application/cms.php:257
3 JApplicationAdministrator->dispatch() /Users/evanion/Projects/php/joomla/libraries/cms/application/administrator.php:152
4 JComponentHelper::renderComponent() /Users/evanion/Projects/php/joomla/libraries/cms/application/administrator.php:98
5 JComponentHelper::executeComponent() /Users/evanion/Projects/php/joomla/libraries/cms/component/helper.php:380
6 require_once() /Users/evanion/Projects/php/joomla/libraries/cms/component/helper.php:405
7 JControllerLegacy->execute() /Users/evanion/Projects/php/joomla/administrator/components/com_mycomponent/mycomponent.php:17
以下是callstack中引用的管理部分mycomponent.php
文件(为清晰起见,删除了一些注释行):
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// Get an instance of the controller prefixed by HelloWorld
$controller = JControllerLegacy::getInstance('Mycomponent');
// Perform the Request task
$controller->execute(JFactory::getApplication()->input->get('task'));
// Redirect if set by the controller
$controller->redirect();
controllers目录在admin文件夹的xml元数据中指定。
答案 0 :(得分:0)
我认为你不能为了你的目的而从JControllerAdmin
延伸。您应该从JControllerForm
或JControllerLegacy
延伸。