Php 从控制器任务joomla调用视图方法
我试图通过MVC创建Joomla2.5组件。我想从task=jump-in入口点将控制器指向view.xml.php中定义的mydisplay()方法。谢谢 /ROOT/components/com_-api/views/api/view.xml.phpPhp 从控制器任务joomla调用视图方法,php,joomla,joomla2.5,joomla-component,joomla-task,Php,Joomla,Joomla2.5,Joomla Component,Joomla Task,我试图通过MVC创建Joomla2.5组件。我想从task=jump-in入口点将控制器指向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.compone
<?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);
}
}
?>
<?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*/
}
}
get('Ister');
//将数据指定给视图
$this->msg=$this->get('xCredentials');
//检查错误。
如果(计数($errors=$this->get('errors'))
{
JError::raiseError(500,内爆(“
,$errors”);
返回false;
}
//显示视图
父::显示($tpl);
}
}
?>
ROOT/components/com\u api/api.php(入口点控制器)
ROOT/components/com\u api/controller.php(带有任务的控制器=跳转)
您可以尝试将其放入控制器的跳转功能中
$view = $this->getView('API');
$view->mydisplay();
试一试
$view = $this->getView('API');
$view->mydisplay();
$view = $this->getView('Api', 'xml');
$view->setModel($this->getModel('Api'), true);
$view->display();