Joomla 3.5子控制器/类

时间:2016-06-22 21:25:41

标签: php joomla

我遇到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元数据中指定。

1 个答案:

答案 0 :(得分:0)

我认为你不能为了你的目的而从JControllerAdmin延伸。您应该从JControllerFormJControllerLegacy延伸。