Reports Developer Guide

Creating Custom Reports

Each report follows the following file structure:

com_reports
|- reports
  !- search_terms
    |- controller.php (optional)
    |- index.html
    |- list.php
    |- mextadata.xml
    |- report.php

controller.php

This is an optional file that allows for tasks to be performed by the report (see the export_csv report for an example).

index.html

This is an empty index file, good practice to always have in a directory.

list.php

This file displays the data returned by the report engine. The data is stored in a view variable:

$this->items

metadata.xml

This is an xml file that holds information about the report. The following shows a simple example:

<?xml version="1.0"?>
<report>
  <name>Users - Registrations</name>
  <author>Andrew Eddie</author>
  <authorEmail>
  This e-mail address is being protected from spambots. You need JavaScript enabled to view it
 </authorEmail>
  <copyright>2005 - 2007 New Life in IT Pty Ltd. All rights reserved</copyright>
  <description>Display the users that registered on a given day</description>
</report>

The XML file must include the xml proglog followed by a report tag to wrap the entire xml document.

You must include a name tag and it is good practice to also provide the author and description tags.

Reports may also nomintate dependancies. For reports that require that are particular component is installed, include the following code block, substituting the option for the actual component you require.

  <requires>
    <component option="com_zine" name="Magazine">
      Available from jxtended.com
    </component>
  </requires>

The option specifies the component that is required.

The name is the actual component name.

The data within the component is an addition message that will be display in the reports listing.

If the component is not installed, the report will not be enabled. It will still display in the list with a message indicating an extension is required for it to run, and also an additional message if specified.

report.php

This is the actual report engine that assembles data to display (in list.php).