调用未定义的方法JController :: getInstance() [英] Call to undefined method JController::getInstance()

查看:155
本文介绍了调用未定义的方法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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆