In this category I will try to write about creating extensions in Joomla!


First, I will start with creating components.

This example, I took from Professional Joomla!, which I simplified, this is not MVC, as much as I think, but it is good as a starting point.

We will create three files: admin.hellopost.php, hellopost.php and hellopost.xml.

hellopost.xml we need for installation and it look like this:

<?xml version="1.0" encoding="utf-8"?>
<install version="1.5.0" type="component">
<author>Stanko Milosev</author>
<description>Hello world, posting from form</description>
<filename component="com_hellopost">hellopost.php</filename>

<menu>Hello post</menu>
<filename component="admin.hellopost">admin.hellopost.php</filename>



Now hellopost.php:


* @version $Id: guestbook.php 5203 2007-06-15 02:45:14Z DanR $
* @copyright Copyright (C) 2007 Dan Rahmel. All rights reserved.
* @package Guestbook
* This component displays guestbook entries and allows the addition
* of entries from registered users.

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

// Check the task parameter and execute appropriate function
switch( JRequest::getVar( 'task' )) {
case 'hello':

// Process data received from form.
function hello() {
echo JRequest::getVar( 'hello' );

// Output a list of guestbook entries
function displayHello() {

<form action="index.php?option=com_hellopost&task=hello" method="post" id="formica" name="formica">
<input type="text" size="20" name="hello" value="Hello world"/>
<input type="submit" value="Submit" name="Submit"/>



With JRequest::getVar( 'task' ) we get variables which we posted ($_POST in pure PHP), my problem is that I coudn't do it with get method.

In case that JRequest::getVar( 'task' ) is equal hello (in PHP would be $_POST['task']=='hello'), than we call hello function in other case we call displayHello.

admin.hellopost.php I didn't change, but I think that file could be even empty. Component you can download from here.