本文介绍了Joomla 3:如何在不向URL添加format = raw的情况下使用原始格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将view.raw.php加载为原始视图,就像我将view = raw附加到URL一样.但我想这样做,而无需在URL中添加view = raw.

I would like to load view.raw.php as a raw view just like if I has appended view=raw to the URL. But I would like to do it without adding view=raw to the URL.

我在主控制器中尝试了以下操作,但无济于事:

I have tried the following inside my main controller and none work:

首先,我尝试了这一点:

First I tried this:

JFactory::$document = null;
JFactory::getDocument();  

然后我尝试了这个:

$input = JFactory::getApplication()->input;
$input->set('format', 'raw');

这:

$_REQUEST['format'] = 'raw';

这: $ urlparams ['format'] ='raw'; $ urlparams [] = array('format'=>'raw');

And this: $urlparams['format']='raw'; $urlparams[]=array('format' => 'raw');

这:

$doc = JFactory::getDocument();            
$doc->setType('raw');

似乎没有一个人能解决问题.

None of them seem to do the trick.

推荐答案

要实现此目的,请在控制器内部添加以下内容:

To achieve this add the following inside the controller:

$document = JDocument::getInstance('raw');  //this new instance is a raw document object
$viewType = $document->getType();
// $viewname below is set in jinput or as you named it
$this->getView($viewName, $viewType); 
$this->input->set('view', $viewName);

上面的代码称为view.raw.php

The above calls the view.raw.php

这篇关于Joomla 3:如何在不向URL添加format = raw的情况下使用原始格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 06:06