Extending GPS Tools using plugin events

Gps Tools is not just full featured but also extendable. There are many plugin events the component triggers which you can use to extend the functionality provided by the component. Plugin events are supported in CS v4 and above only.

Creating a plugin

Please read the following documentation to know about creating a Joomla! plugin. The process is same for any plugin.

The best way to get started on creating the plugin is to refer to the default “Gps Tools – Tracks” plugin provided with the Gps Tools package. It is the full featured implementation of most of the plugin events.

Following is the sample class without any plugin events declared. The plugin name is “Pluginname“, and the class name is prefixed with PlgGpsTools. Create the php file with the name pluginname.php where pluginname is name of your plugin (for example tracksoverride.php)

 * @package     corejoomla.administrator
 * @subpackage  com_gpstools
 * @copyright   Copyright (C) 2009 - 2015 corejoomla.com. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
defined('_JEXEC') or die;
require_once JPATH_ROOT.'/components/com_cjlib/framework/api.php';
require_once JPATH_ROOT.'/components/com_gpstools/router.php';
require_once JPATH_ROOT.'/components/com_gpstools/helpers/route.php';
class PlgGpstoolsPluginname extends JPlugin
	public function __construct(& $subject, $config)
		parent::__construct($subject, $config);
		$this->loadLanguage('com_gpstools', JPATH_ROOT);

Plugin Events

Gps Tools defines a set of plugin events which you can listen to extend the functionality. The following are the plugin events:


This event will be triggered before saving the track to database. Return false from this event will stops saving the track.

public function onTrackBeforeSave($context, $track, $isNew)
   // do your stuff
   return true;


This event will be fired before deleting a track.

public function onTrackBeforeDelete($context, $track)
   // do your stuff
   return true;


This event will be triggered before any change of the state of a track(s) such as unpublishing, trashing or deleting.

public function onTrackChangeState($context, $pks, $value)
   // do your stuff
   return true;


This event will be fired after saving the track to database.

public function onTrackAfterSave($context, $track, $isNew)
  // do your stuff


This event will be fired after deleting one or more tracks.

public function onTrackAfterDelete($context, $track)
  // do your stuff

Plugin installer

Finally you need to have your plugin installer xml file as shown below. Create the xml file with name pluginname.xml where pluginname is name of your plugin.

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="gpstools" method="upgrade">
    <name>Gps Tools - YourPlugin</name>
    <author>Your Name</author>
    <authorEmail>Your email</authorEmail>
    <authorUrl>Your email</authorUrl>
    <copyright>All rights reserved by your company 2003-15.</copyright>
    <license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
    <description>Some description</description>
        <filename plugin="pluginname">pluginname.php</filename>
        <fields name="params">
            <fieldset name="basic">


Now zip both xml and php files into a zip file using your favorite archive tool such as winzip, 7-zip etc. You can now install the package using Joomla! installer.