【发布时间】:2014-09-19 14:22:16
【问题描述】:
全部,
我正在尝试开发我的第一个 Joomla 组件,我正在关注 here 的 MVC 教程。
但我无法取得太大进展,因为我收到以下错误。
#0 Invalid controller class: AbcController
我已启用调试跟踪,但在以下行出现错误:
JControllerLegacy::getInstance()
不用说,我已经花了很长时间寻找解决方案,但找不到任何解决方案。
我正在努力:
OS: Windows 8.1
PHP version: 5.5.6
MySQL version: 5.6.16
Joomla version: Joomla! 3.3.1 Stable
我遵循以下步骤:
-
在扩展表中创建了一个条目。
插入
abc.abc_extensions(extension_id,name,type,element,folder,client_id,enabled, @98765433@4, @98765433@4 987654336@,params,custom_data,system_data,checked_out,checked_out_time,ordering,state) 价值观 (701, 'com_abc', 'component', 'com_abc', '', 1, 1, 1, 0, '{"name":"com_abc","type":"component","creationDate":"July 2014","author":"ABC Project","copyright":"(C) 2005 - 2014 开源事务。保留所有权利。\n\t","authorEmail":"admin@joomla.org"," authorUrl":"www.abc.org","version":"1.0.0","description":"COM_ABC_DESCRIPTION","group":""}', '{"enabled":"0","show_date ":"1"}', '', '', 0, '0000-00-00 00:00:00', 0, 0); -
主要组件代码mysite/component/com_abc/abc.php是;
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import joomla controller library jimport('joomla.application.component.controller'); // Get an instance of the controller prefixed by HelloWorld $controller = JControllerLegacy::getInstance('Abc'); // Perform the Request task $input = JFactory::getApplication()->input; $controller->execute($input->getCmd('task')); // Redirect if set by the controller $controller->redirect(); -
控制器代码mysite/component/com_abc/controller.php为:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla controller library jimport('joomla.application.component.controller'); /** * Hello World Component Controller */ class AbcController extends JControllerLegacy { } -
视图文件 mysite/component/com_abc/views/main/view.html.php 包含:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla view library jimport('joomla.application.component.view'); /** * HTML View class for the HelloWorld Component */ class AbcViewMain extends JViewLegacy { // Overwriting JView display method function display($tpl = null) { // Assign data to the view $this->msg = 'Hello World'; // Display the view parent::display($tpl); } } -
模板文件mysite/component/com_abc/views/main/tmpl/default.php包含:
<?php // No direct access to this file defined('_JEXEC') or die('Restricted access'); ?> <h1><?php echo $this->msg; ?></h1> 使用 index.php?option=com_abc&view=main
调用视图
如果您能帮助我解决问题,不胜感激。
非常感谢。
【问题讨论】: