Publisher - Elo
Welcome, Guest
Main » Articles

Total entries in catalog: 1
Shown entries: 1-1

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 "">
<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:


Joomla | Views: 2251 | Added by: EloPaint | Date: 2011-09-27 | Comments (0)