This is a very simple admin only component.
Reading all the documentation I could find on Joomla 3.3 coding standards I see that you should have a separate controller for each view, so keeping inline with this I'm trying to call a specific controller, but everytime I do my base controller.php file is called.
For example I have the following url in my component :
/administrator/index.php?option=com_que ... sk=runtest
I was expecting the above url to call the controller called test (which would be filename controller/test.php).
Then it would run function runtest from that controller.
So it should open file controllers/test.php
Run the function runtest in the test.php controller
Then open the runtest view (file views/runtest/view.html.php (using layout default which is file views/runtest/tmpl/default.php))
What is actually happening is that my base controller (controller.php) is called and the display function inside the controller is called and the test view is displayed.
The code from my base file (questaudit.php) is listed below :
Code: Select all
defined( '_JEXEC' ) or die( 'Restricted access' );
if (!JFactory::getUser()->authorise('core.manage', 'com_questaudit'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
$controller = JControllerLegacy::getInstance('Questaudit');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
Code: Select all
defined('_JEXEC') or die;
class QuestAuditController extends JControllerLegacy
{
protected $default_view = 'questaudits';
function __construct()
{
parent::__construct();
}
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT.'/helpers/questaudit.php';
$view = $this->input->get('view', 'questaudits');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
//die("View is {$view}, layout is {$layout} and id is {$id}");
parent::display($cachable);
}
}