view.raw.php

263 views
Skip to first unread message

Pedro Renan

unread,
Jul 29, 2009, 1:52:43 PM7/29/09
to Joomla! CMS Development
Hi. How do I define the output to be in raw format (format=raw). In
the controller i know that i can set the layout doing:
JRequest::setVar("layout", "mylayout");
Can I define the format in a similar way? Or its done in a differently?

Andrew Eddie

unread,
Jul 29, 2009, 6:01:43 PM7/29/09
to joomla-...@googlegroups.com
Set it in:

function &getView( $name = '', $type = '', $prefix = '', $config = array() )

In your controller:

$document = &JFactory::getDocument();
$lName = JRequest::setVar("view", "articles");
$vType = $document->getType();

if ($view = &$this->getView($vName, $vFormat)) { do something

Hope this helps.

Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer




2009/7/30 Pedro Renan <pedro...@gmail.com>:

Pedro Renan

unread,
Jul 29, 2009, 7:05:05 PM7/29/09
to Joomla! CMS Development
Ok it worked, i've managed to call the view.raw.php, but it is
generating a different data than i wanted. What i want is that the
data output to be equal to the output i get when i define the format
by GET (www.site.com.br/index.php?option=com_component&FORMAT=RAW)

thks.


On 29 jul, 19:01, Andrew Eddie <mambob...@gmail.com> wrote:
> Set it in:
>
>         function &getView( $name = '', $type = '', $prefix = '', $config = array() )
>
> In your controller:
>
> $document = &JFactory::getDocument();
> $lName = JRequest::setVar("view", "articles");
> $vType = $document->getType();
>
> if ($view = &$this->getView($vName, $vFormat)) { do something
>
> Hope this helps.
>
> Regards,
> Andrew Eddiehttp://www.theartofjoomla.com- the art of becoming a Joomla developer
>
> 2009/7/30 Pedro Renan <pedrore...@gmail.com>:

Pedro Renan

unread,
Jul 30, 2009, 11:30:45 AM7/30/09
to Joomla! CMS Development
Well, I didn't managed to pass the parameter to the component by
controller to call the view in the raw format, so i tried another
thing: i've made a button in the toolbar calling a task that redirects
to
index.php?option=com_mycomponent&view=myview&task=TASK&format=raw
where my controller executed
JRequest::setVar('layout', "mylayout"),
and it worked!

So i ask this question: is there a difference making it like this?
With the format=raw output i manage to generate my xls output
properly.

Louis Landry

unread,
Jul 30, 2009, 12:38:36 PM7/30/09
to joomla-...@googlegroups.com
Another thing you can do is swap out the document object... something like the following should work:

// Swap out the document object for the remainder of the request.

$document = & JFactory::getDocument();

$document = & JDocument::getInstance('raw');


If you put that at the top of your controller task, the system should use the JDocumentRaw object you created as the system document object from then on.  Might save you a redirect.

- Louis
--
Development Coordinator
Joomla! ... because open source matters.
http://www.joomla.org
Reply all
Reply to author
Forward
0 new messages