Вам нужно создать папку в главном каталоге вашего компонента (например, components / com_mycom / controllers /...)
Затем основной файл моего компонента (его нужно назвать "mycom.php", используяв приведенном выше примере) есть код, который выглядит следующим образом:
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// load a constants file for use throughout the component
require_once(JPATH_COMPONENT.DS.'lib'.DS.'constants.php');
// fetch the view
$view = JRequest::getVar( 'view' , 'null' );
// use the view to fetch the right controller
require_once( JPATH_COMPONENT.DS.'controllers'.DS.$view.'.php' );
// initiate the contoller class and execute the controller
$controllerClass = 'MycomController'.ucfirst($view);
$controller = new $controllerClass;
// call the display function in the controller by default - add a task param to the url to call another function in the controller
$controller->execute( JRequest::getVar( 'task', 'display' ) );
$controller->redirect();
Тогда для ваших контроллеров в каталоге контроллеров ваш код будет обычным, например:
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.application.component.controller');
class MycomControllerAdd extends JController
{
function display() {
$viewLayout = JRequest::getVar( 'tmpl', 'add' );
$view = &$this->getView( 'add', 'html' );
$model = &$this->getModel( 'add' );
$view->setModel( $model, true );
$view->setLayout( $viewLayout );
$view->addStuff();
}
...
URL, который будет вызыватьэто будет выглядеть так:
http://somedomain.com/index.php?option=com_mycom&view=add