Plugin is an extension which provides a function that is associated with any trigger events. Following are the files required for creating a simple custom plugin in Joomla.
1 myfirsttest.xml
2 myfirsttest.php
3 index.html
First for creating a custom plugin we need to create an xml file which includes information about the author of plugin and what files are required for that plugin.
<extension version="2.5" type="plugin" group="content">
<name>plg_content_myfirsttest</name>
<author>Kshitiz dixit</author>
<creationdate>december 18th, 2015</creationDate>
<copyright>Evontech</copyright>
<license>GNU General Public License</license>
<authoremail>kshitiz.dixit@evontech.com</authoremail>
<authorurl>http://www.evontech.com</authorurl>
<version>1.0</version>
<description>Simple custom plugin which prints text in any article content.</description>
<files>
<filename plugin="myfirsttest">myfirsttest.php</filename>
<filename>index.html</filename>
</files>
</creationdate></extension>
Next step is to create a php file which does all the work. As we are creating a content based plugin name my firsttest, so file should be saved as myfirsttest.php.
<?php
defined('__JEXEC') or die;
class plgContentMyfirsttest extends JPlugin
{
public function onContentAfterTitle($context, &$article, &$params, $limitstart)
{
return "my first test plugin created successfully!";
}
}
?>
Next and last step is to create an index.html file in which we don't need to place any code inside that file and compress into a zip file name as myfirsttest.zip.
0 Comment(s)