Got a question? Ask a developer in our Developer's Corner Forum
| Joomla! Component Execution Path Walkthrough |
Page 1 of 5 Note: If you have not already read Joomla! Execution Path Walkthrough, you may want to read it first.
The entry point into a Joomla! component is similar from component to component. For this example, we will use the Web Links core component. The first file to be executed in the front end is: .../components/com_weblinks/weblinks.php
First we see the security check to make sure no one calls this page directly. This is standard and should be in all your php files (although there are a few exceptions): // no direct access defined('_JEXEC') or die('Restricted access');
Next, we require (include) the controller.php class that is in the same directory: // Require the base controller require_once (JPATH_COMPONENT.DS.'controller.php');
We check the query string to see if a specific controller name was sent in. If so, we make sure to require the required file in the controllers directory as well:
// Require specific controller if requested if($controller = JRequest::getWord('controller')) {
$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
if (file_exists($path)) {
require_once $path;
} else {
$controller = '';
}
}
We then create an instance of our controller using the name we set above: // Create the controller $classname = 'WeblinksController'.ucfirst($controller);
$controller = new $classname( );
And execute the task that was requested in the query string parameter: // Perform the Request task $controller->execute(JRequest::getCmd('task'));
Once the task is complete, we redirect if needed: // Redirect if set by the controller $controller->redirect();
Next, we open up the controller class.
|

