Welcome, Guest
Main » Articles » Joomla

Joomla Hello World plugin tutorial

This is a tutorial for creating very simple content-plugin "Hello World" for Joomla 1.5 native.

1. Create a folder plg_helloworld on your local computer.

2. Create two text files encoded in UTF-8 in it, and name it helloworld.xml and helloworld.php

3. Example of code for file helloworld.xml is here:

<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/plugin-install.dtd">
<install version="1.5" type="plugin" group="content">
<name>Content - Hello World</name>
<description>This is Joomla 1.5 content plugin, that replace {helloworld} for "Hello world!" text everywhere in the website content.</description>
<filename plugin="helloworld">helloworld.php</filename>

4. Example of code for helloworld.php file:

defined( '_JEXEC' ) or die( 'Restricted access' );
// import library dependencies
class plgContentHelloworld extends JPlugin
    function plgContentHelloworld( &$subject )
        parent::__construct( $subject );
    function onPrepareContent( &$row, &$params, $limitstart=0 )
        //plugin codes here
        if (preg_match("#{helloworld}#s", $row->text)) {
            $helloworldCode = 'Hello world!';
            $row->text = preg_replace("#{helloworld}#s", $helloworldCode, $row->text);
        //no return value

5. Zip folder plg_helloworld, load and instal it on Joomla 1.5 as usual. Enable plugin "Content - Hello World" in Joomla.

6.Write {helloworld} somewhere in article and you look text "Hello world!" in this place. That's all :)

You can download source code by this link: plg_helloworld.zip


Category: Joomla | Added by: EloPaint (2011-09-27)
Views: 2997 | Rating: 0.0/0
Total comments: 0
Only registered users can add comments.
[ Registration | Login ]