Shika: Report type plugins

Reports type plugins

Shika comes with a reporting tool. Basically all the report in shika are plugins and hence anyone can build there own plugin to get any kind of reports they want.


In this document you will be learning how to build a report plugin for Shika




The plugin type for your report plugin should be “tjlmsreports”


Here are the functions which are necessary to build a report plugin


Note - ‘YOUR_REPORT’ is the name of your plugin.


The 1st function which is called by shika is "plgYOUR_REPORTRenderPluginHTML"


public function plgYOUR_REPORTRenderPluginHTML($filters, $colNames, $rows_to_fetch, $limit_start, $sortCol, $sortOrder, $action, $layout = 'default')
		// Get data for your report
		$resultData = $this->plgYOUR_REPORTGetData($filters, $colNames, $rows_to_fetch, $limit_start, $sortCol, $sortOrder);

		// Get Items
		$userReportData = $resultData['items'];

		// Coulmns to show
		$colToshow       = $resultData['colToshow'];

		// Columns which are used for search fields
		$showSearchToCol = $this->showSearchToCol();
		$html            = '';

		// Load the layout & push variables
		$layout = dirname(__FILE__) . '/' . $this->_name . '/' . 'tmpl' . '/' . $layout . '.php';
		include $layout;

		$html = ob_get_contents();

		$result               = array();
		$result['total_rows'] = $resultData['total_rows'];
		$result['html']       = $html;

		return $result;



Parameters breakdown

  • $filters

    • All the filters that are applied already. Basically it's an array which have indexes as the column name and its value.

  • $colNames

    • All the columns which needs to be shown. Its an array.

  • $rows_to_fetch

    • Number of records that needs to be fetched at a time.

  • $limit_start

    • Starting row which we can apply to our query.

  • $sortCol

    • Column name which we want to sort by.

  • $sortOrder

    • Sort the Column the with either ASC or DESC

  • $action

    • // Not used yet

  • $layout

    • Which layout we should used for rendering html.


To get data for your record

public function plgYOUR_REPORTGetData($filters, $colNames, $rows_to_fetch, $limit_start, $sortCol, $sortOrder)
		$db        = JFactory::getDBO();
		$mainframe = JFactory::getApplication('admin');

		// Get all Columns
		$allColumns = $this->plgYOUR_REPORTgetColNames();

		// Get only those columns which user has to show
		$colToshow  = array_intersect($allColumns, $colNames);

		// Columns which has search fields
		$showSearchToCol = $this->showSearchToCol();

		$query = // Your query considering all the columns you need
$total_rows = // Total result available
$items = // Your result array

$result               = array();
		$result['total_rows'] = $total_rows;
		$result['items']      = $items;
		$result['colToshow']  = $colToshow;

		return $result;


Get Columns name for your report


public function plguserreportgetColNames()
		$ColArray = array(

		// Create an array where index should be Language constant and value as the column name of the table. 
		return $ColArray;


Get the column names on which you want filters to be applied


public function showSearchToCol()
		$filterArray = array(

		return $filterArray;


Finally you will require a layout file to print the html


For this you can simply copy any default.php form any available reports plugin. You will need to change the report name wherever necessary.