3

I am trying to upgrade a component from joomla2.5 to joomla 3 but I am getting this error:

Fatal error: Call to undefined method JController::getInstance() in /home/evolve13/public_html/components/components/com_donation/donation.php on line 9

Here is the code of donation.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 Donation
JController::getInstance('Donation');

// Perform the Request task
$controller->execute(JRequest::getCmd('task'));

// Redirect if set by the controller
$controller->redirect();
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Fredrick Boaz
  • 159
  • 2
  • 7
  • Please try asking your question over at [Joomla StackExchange](http://joomla.stackexchange.com) ;) – Lodder Dec 06 '14 at 14:22
  • possible duplicate of [Call to undefined method JController::getInstance()](http://stackoverflow.com/questions/17901808/call-to-undefined-method-jcontrollergetinstance) – Saurabh Chandra Patel Jan 21 '15 at 07:14

1 Answers1

3

On Joomla 3X you need to use the legacy controllers... try the following code. Change JController::getInstance('Donation');
To JControllerLegacy::getInstance('Donation');