maurodefilippis
maurodefilippis

Reputation: 19

Joomla Component override template

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

Upvotes: 0

Views: 350

Answers (1)

piotr_cz
piotr_cz

Reputation: 9608

  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);

Upvotes: 1

Related Questions