Step 1: In options.xml, add a node/graph and define parameters in it
Define Function Name:
Create a function
<function name=”function”
Give name to plugin you are going to create as
element=”plugin_name”
To upload image to the plugin, enter source path of image as
img=”path/image.png”
To add description if any to plugin, enter description as
description=”description if any”
The title of the node/graph is defined as
title=”TITLE”
Close the function
</function>
For example:
<hranalyticstopbar name="hranalyticstopbar" element="hrmsanalytics" img="components/com_dashboard/assets/images/intranet_summary.png" description="" title="HR Analytics Top bar">
.
.
.
</ hranalyticstopbar >
Define Parameters:
Once you create a function, write parameters of the plugin in it. The parameters of functions are defined as below:
<params>
.
.
.
</params>
Add Fields:
Define fields required for the plugin one by one in parameters you created
For example:
<params >
<fields name="params">
<fieldset name="basic">
<field type="users" name="users" label="Users" description="The graph will be available for only selected users" />
<field type="text" default="7" name="noofdays" label="No Of Days" description="No Of Days" />
<field type="text" default="10" name="limit" label="Limit" description="Enter the data points limit here." />
</fieldset>
</fields>
</params>
Step 2: Call the function you defined in option.xml file in your php plugin file by function getOptions() as below:
function getOptions()
{
if(file_exists(dirname(__FILE__).'/options.xml'))
$xml = simplexml_load_file(dirname(__FILE__).'/options.xml');
$options = array();
foreach($xml as $key=>$eachoption)
{
$options[$key] = $eachoption;
}
return $options;
}
Note: This is the mandatory function which will call your custom methods which you have defined in above function named hranalyticstopbar
Step 3: Each plugin can have a function called onCreateDashboard($user_id), $user_id is the parameter the current logged in user
The function may return an object or array of objects, each object to have following attributes
$title - Initial Title of the graph
$type - will be an array of 3 elements:
1. plugin_type - folder of plugin .i.e. system, hrm, attendnace, etc
2. plugin_name - The name of the plugin like uknowva, community, etc
3. function - the function that will plot the graph
$params - associative array of the parameters which the function accepts to plot the graph
$menu - String, the name of the menu in which this dashboard node will be shown, if not there, then the menu should get automatically created
For example:
function onCreateDashboard($user_id = 0)
{
if(empty($user_id))
{
$user_id = JFactory::getUser()->id;
}
$return = array ();
$object = new stdClass();
$object->title = 'HR Stats';
$object->column = 2;
$object->customclass = 'hrmsanalytics_topbar';
$object->type = array('hrm','hrmsanalytics','hranalyticstopbar');
Here, hrm indicates type of plugin, hrmsanalytics name of plugin and hranalyticstopbar name of function. Now you need to define the same in the same file
Define function after completion of create dashboard function.
$object->menu = 'HR Analytics';
$return[] = $object;
return $return;
}