I'm trying to add a custom JToolbar
button to my list view that will export the list contents to excel. I created a new task in my list controller to render the raw view class in a file called view.raw.php. However I can't get the content to load the raw data only.
I copied the relevant controller code from com_banners tracks.raw.php controller
Controller method:
public function exportToExcel()
{
// Get the document object.
$document = JFactory::getDocument();
$vName = 'Mylist';
$vFormat = 'raw';
// Get and render the view.
if ($view = $this->getView($vName, $vFormat))
{
// Get the model for the view.
$model = $this->getModel($vName);
// Push the model into the view (as default).
$view->setModel($model, true);
// Push document object into the view.
$view->document = $document;
$view->display();
}
}
And a simple test display method in my view.raw.php file:
public function display($tpl = null)
{
echo "Test";
}
This displays "Test" but loads the template too.
I've tried using $document->setType('Raw')
but this is giving me an
Unable to load renderer class
error.
The reason for this is that it is looking for
libraries/joomla/document/raw/renderer/modules.php
which does not exist.
Maybe I'm going about this in the wrong way but how should I do this correctly?