joomla控制器如何工作?

fef*_*efe 5 model-view-controller joomla

我正在努力了解如何从joomla组件调用子控制器.什么将被放置在控制器文件夹中?

我的组件的入口点像 -

<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// require helper file
JLoader::register('TieraerzteHelper', dirname(__FILE__) . DS . 'helpers' . DS . 'my_helper.php');

// import joomla controller library
jimport('joomla.application.component.controller');

$controller = JController::getInstance('MyController');  

// Get the task
$jinput = JFactory::getApplication()->input;
$task = $jinput->get('task', "", 'STR' );

// Perform the Request task
$controller->execute($task);

// Redirect if set by the controller
$controller->redirect();
Run Code Online (Sandbox Code Playgroud)

然后,如果我想调用一个放在controllers文件夹中的控制器,我该怎么做?

Bak*_*ual 7

你做了 task=controller.function

举个例子:你想调用MycomponentControllerFooin /controllers/foo.php并执行该函数bar().您使用以下URL来调用它:

index.php?option=com_mycomponent&task=foo.bar
Run Code Online (Sandbox Code Playgroud)

或者,您可以使用存在隐藏任务字段的表单.