0
votes

I'm writing a Joomla 2.5 or 3.x component which make data elaboration and returns some data.

I want that work as a service that is invoked and returns data (eg I call www.mysite.com?option=com_mycomponent&view=myview

and result for example my json data ..or xml or what i need after my elaboration )

so i need that my output view is raw. i need no template and no css or js.. only my result..

but now the results are inserted into the template

Is it possible?...

I tried to create a RAW mode in my template like Here .

this works but is not what I want but it is a dirty solution because it work if the url i have to call is like ... www.mysite.com~....~&tmpl=raw

I'd like my component can output as raw.

Thanks

1
You will find these useful: raw format view ,and, json output.ilias
Or you can just output data and die in view.raw.phpdi3sel

1 Answers

1
votes
  1. Create RAW view views/[myview]/view.raw.php inside your component
  2. In requests require RAW format index.php?option=com_mycomponent&view=myview&format=raw.

Like in com_banners/views/tracks/view.raw.php.

Sames goes for JSON and XML.

Here's a list of generic document formats: libraries/joomla/document

  • feed
  • html
  • image
  • json
  • opensearch
  • raw
  • xml

To use JSON format in response, I recommend new JResponseJson class:

// Anything that may be serialized with json_encode or an Exception
$data = array('some' => 'data');

echo new JResponseJson($data);