[英]joomla error : #0 Invalid controller class:
所有,
我正在嘗試開發我的第一個Joomla組件,並且在這里關注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
, access
, protected
, manifest_cache
, params
, custom_data
, system_data
, checked_out
, checked_out_time
, ordering
, state
)VALUES(701,'com_abc','component','com_abc ','',1,1,1,0,'{“ name”:“ com_abc”,“ type”:“ component”,“ creationDate”:“ 2014年7月”,“ author”:“ ABC Project”,“ copyright“:”(C)2005-2014 Open Source Matters。保留所有權利。\\ n \\ t“,” authorEmail“:” admin@joomla.org“,” authorUrl“:” www.abc.org“,” version “:” 1.0.0“,”描述“:” COM_ABC_DESCRIPTION“,”組“:”“}','{”啟用“:” 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調用該視圖
謝謝您能幫助我解決問題。
非常感謝。
// import Joomla controller library
jimport('joomla.application.component.controller');
不確定您在做什么,沒有類似的文件,新的和舊的控制器類位於各自的控制器文件夾中。 但是無論如何它們都是自動加載的,所以這不是您的問題。
更重要的是,我建議您在控制器中放入一些代碼,特別是一種顯示方法,該方法為組件設置默認視圖。 看看任何核心組件,您都會明白我的意思。 就像在JControllerLegacy :: display doc塊中所說的:
我有同樣的問題。 查看您所有的類名,並確保它們遵循Joomla命名規則。 您的控制器必須在站點文件夾中命名為AbcController。 還要回顧您的觀點,我認為它們也會給您帶來問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.