Wednesday, October 14, 2009

Joomla 1.5 - Creating RAW output for the front end

If you want your component to create RAW output on the front end, like xml data to be returned for an AJAX POST/GET, then this is what you have to do.

1. In your component's views/view/ folder, add a view.raw.php file. E.g. if your component has a view called smile your will add view.raw.php to your views/smile/ folder . i.e. com_mycomponent/views/smile/view.raw.php

2. Whenever you call your component via a url simply append format=raw to the url. E.g. index.php?option=com_mycomponent&format=raw

Notes: For the backend administrator side, you can just specify format=raw without having to add the view.raw.php file to your views folder.