Call to undefined method JController::getInstance()(调用未定义的方法 JController::getInstance())
问题描述
我似乎什么都试过了.我正在尝试学习如何创建一个新组件,目前我的文件夹结构如下所示(请注意该组件已安装).
i seem to have tried everything. I am trying to learn how to create a new component and currently my folder structure looks like this (please note that the component does install).
这是我的文件夹结构图:
This is a picture of my folder structure:
我关闭了其中的一些,因为我发现它无关紧要,但是如果您需要查看其中的内容,请告诉我.
Ive closed some of it because i found it irelevant but please if you need to see whats inside of them please let me know.
正如我上面所说的,组件安装没有问题.但是,当我尝试访问它时,出现以下错误:
as i stated above the component does install without problems. however when i try to access it i get the following error:
Fatal error: Call to undefined method JController::getInstance() in /home/marcrasm/public_html/Joomla/administrator/components/com_helloworld/helloworld.php on line 13
现在它引用的文件是这个:
Now the file it is refering to is this one:
<?php
defined('_JEXEC') or die ('Restricted access');
jimport('joomla.application.component.controller');
$doc = JFactory::getDocument();
$doc->addScript("/components/com_helloworld/js/jquery.js");
$doc->addScript("/components/com_helloworld/js/com_helloworld_script.js");
$doc->addStyleSheet("/components/com_helloworld/css/com_helloworld_layout.css");
// gets the instance of the controller
// Get an instance of the controller prefixed by HelloWorld
$controller = JController::getInstance('HelloWorld');
// Perform the Request task
$input = JFactory::getApplication()->input;
$controller->execute($input->getCmd('task'));
// Redirect if set by the controller
$controller->redirect();
我知道这很难说,但有人知道问题出在哪里吗?
I know it can be hard to tell but does anyone know what the problem might be?
推荐答案
请查看Joomla版本
Please check Joomla version
在 3.X 中
$controller = JControllerLegacy::getInstance('HelloWorld');
在 2.X 中
$controller = JController::getInstance('HelloWorld');
这篇关于调用未定义的方法 JController::getInstance()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:调用未定义的方法 JController::getInstance()
基础教程推荐
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
