duancan8382 2013-07-27 19:44
浏览 41
已采纳

调用未定义的方法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:

enter image description here

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?

  • 写回答

3条回答 默认 最新

  • dongshi3061 2014-04-17 04:45
    关注

    Please check Joomla version

    In 3.X

       $controller  = JControllerLegacy::getInstance('HelloWorld');
    

    In 2.X

       $controller = JController::getInstance('HelloWorld');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 ue5运行的通道视频都会有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数