Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从控制器任务joomla调用视图方法_Php_Joomla_Joomla2.5_Joomla Component_Joomla Task - Fatal编程技术网

Php 从控制器任务joomla调用视图方法

Php 从控制器任务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

我试图通过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.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();