Chapter 4
[ 83 ]
For each major entity, you should identify the tasks associated with each. You can
use the table in the previous section, which identified common task and method
names to help identify tasks.
We have seen how to build models, views, and controllers but we have yet to see
how we actually use them. To get started we need to create a PHP file named after
the component in the component's frontend folder and we need to create a PHP
file named after the component and prefixed with admin. in the component's
backend folder.
These files are executed when the component is invoked via the frontend and backend
respectively. This example shows how we might implement one of these files:
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted Access');
// get the controller
require_once(JPATH_COMPONENT.DS.'controller.php');
// instantiate and execute the controller
$controller = new MyextensionController();
$controller->execute(JRequest::getCmd('task', 'display'));
// redirect
$controller->redirect();
You will often find that these files are relatively simple.
Pages:
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125