Customizing JSON

With Preachit 4.1 we have added the ability to override the JSON output. This will allow developers to add additional information, modify information or remove information as needed.

 

To make use of this you need to follow these instructions:

 

+ Create a folder called json in the root folder of your Joomla template.


+ Create a folder called com_preachit within the json folder created in step 1.


+ Create folders for each of the views where you want to override the json output. The full list of folders that can be used here are: booklist, datelist, ministrylist, serieslist, study, studylist, taglist, teacherlist.


+ In each of these folders create a file called jsonfeed.php. This is the display file for the output.


jsonfeed.php file

 

Below is an example code for a jsonfeed.php file. $this->items is the details array object that is passed from the view file to the display file. If the view is a list view then you will need to run through each row in the array object in a foreach loop if you want to add details to it.

 

// no direct access

 

defined( '_JEXEC' ) or die( 'Restricted access' );

 

// Set the MIME type for JSON output.

 

header('Content-type: application/json');

header('Cache-Control: no-cache, must-revalidate');

 

// determine if there is a particular call back needed to approve the JSON

 

$app = JFactory::getApplication();

$option = $app->input->getCmd('option', '');

$callback = $app->input->get('callback');

$json = json_encode($this->items);

if($callback)

{$json = $callback . "(". $json .")";}

 

// print the $json object

 

print_r($json);

jexit();

Cron Job Starts