我正在尝试通过 MVC 创建 Joomla2.5 组件。我想从入口点的 task=jump 将控制器定向到 view.xml.php 中定义的 mydisplay() 方法。谢谢。
/ROOT/components/com_api/views/api/view.xml.php
<?php
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
/**
* XML View class for the Api Component
*/
class ApiViewApi extends JView
{
// Overwriting JView display method
function mydisplay($tpl = null)
{
//echo JRequest::getVar('task');
//$this->get('Ister');
// Assign data to the view
$this->msg = $this->get('xCredentials');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Display the view
parent::display($tpl);
}
}
?>
ROOT/components/com_api/api.php(入口点控制器)
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import joomla controller library
jimport('joomla.application.component.controller');
// Get an instance of the controller prefixed by Api
$controller = JController::getInstance('Api');
// Perform the Request task
$controller->execute(JRequest::getCmd('task'));
$controller->redirect();
?>
ROOT/components/com_api/controller.php(任务=跳转的控制器)
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* Api Component Controller
*/
class ApiController extends JController
{
function jump()
{
//parent::display();
/* invoke mydisplay method from view.xml.php, located in views*/
}
}
执行 task=jump 后如何在 view.xml.php 中调用 mydisplay() 方法?