How to create your own plugin in joomla
to create your own plugin in joomla bascically you need two file s one is installation file(i.e. xml file) and other one is php file. you can zip both file and install it with joomla bcs joomla allow zip installation.
bcs the editor that i am currently using changes the tags so i attached a file xml.txt make this file testing.xml first for the testing plugin. where testing is your plugin name.
pls see the attached file first to proceed
after checking the attached file(installation file) now you need to create Plugin or testing.php file
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// Import library dependencies
jimport('joomla.event.plugin');
class plg extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for
* plugins because func_get_args ( void ) returns a copy of all passed arguments
* NOT references. This causes problems with cross-referencing necessary for the
* observer design pattern.
*/
function plg( &$subject )
{
parent::__construct( $subject );
// load plugin parameters
$this->_plugin = > JPluginHelper::getPlugin( '', '' );
$this->_params = new JParameter( $this->_plugin->params );
}
/**
* Plugin method with the same name as the event will be called automatically.
*/
function ()
{
global $mainframe;
// Plugin code goes here.
return true;
}
}
Using Plugins in Your Code
Now that you’ve created your plugin, now you need to call it in your code. the Joomla! core has a number of built-in events that you might want your plugin code to be registered to. In which case you don’t need to do the following.
If you want to trigger an event then you use code like this:
$results = $mainframe->triggerEvent( '', ); It is important to note that the parameters have to be in an array. The plugin function itself will get the parameters as single values. The return value will consist of an array of return values from the different plugins (so it can also contain multilevel arrays).
- Login or register to post comments
Delicious
Digg
StumbleUpon
Facebook
Google
Yahoo
Technorati
Icerocket

Sign In





