Mastering Joomla! 1.5 Extension and Framework Development Second Edition

By Chuck Lanham , James Kennard
    What do you get with a Packt Subscription?

  • Instant access to this title and 7,500+ eBooks & Videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Introduction to Joomla!

About this book

Joomla! is one of the world’s top open source content management systems, which enables you to build websites and powerful online applications. Out of the box, Joomla! does a great job of managing the content needed to enhance the functionality of your website. But for many people, the true power of Joomla! lies in its application framework that makes it possible for thousands of developers around the world to create powerful add-ons and extensions.

This book will guide you through the complexities of implementing add-ons, components, modules, and plugins in Joomla! 1.5. If you feel that you’ve mastered the basics of creating Joomla! extensions, then this book will take you to the next level. Packed with expert advice on all aspects of programming with Joomla!, this book is an invaluable reference guide you will turn to again and again for your Joomla! development tasks.

The book starts by explaining the structure and design of the Joomla! Framework. Then we move on to extending and storing data in standard fields and dealing with multilingual requirements. Further, you will discover best practices, design, and coding methods for Joomla! components, modules, plugins, and other extensions. Along the way, you will actually design and create a component, module, and plugin that work together to add functionality to the Joomla! framework.

You will also learn about customizing the page output using JavaScript effects, making use of Web Services from within Joomla! and ensuring that your code is secure and error-free. You will discover how to easily create sophisticated extensions that are robust, user-friendly, and professional by taking advantage of the many libraries and utilities provided by the Joomla! framework. A comprehensive, up-to-date reference to the Joomla! Framework API is also included in the book.

Finally, we will discuss advanced methods for rendering your extensions more robust, secure, and professional.

Publication date:
May 2010


Chapter 1. Introduction to Joomla!

Joomla! 1.5 is based on a comprehensive and flexible framework that is easily and securely extended through a wide variety of extensions. In this chapter, we will introduce the Joomla! framework and learn how, as developers, we can easily extend it beyond its core functionality. This chapter will cover the following:

  • An overview and introduction to the Joomla! 1.5 framework

  • An introduction to Joomla! Extensions

  • An overview of the requirements to create and manage a Joomla! website

  • A summary of available development tools and coding standards


Joomla! is a modular and extensible PHP MySQL CMS (Content Management System). It is an open-source project, which is released under version 2 of the GPL license. Joomla! has fast become one of the most popular open source CMS's, which is proved by its numerous awards and massive online community.

One of the things that has made Joomla! so popular is the large number of freely and commercially available extensions which enable users to do far more than simply manage content. Extensions perform many tasks, generally classified in categories such as:

  • Ads & Affiliates

  • Calendars & Events

  • Communication (Chat Rooms, Forums, Guest Books, Mailing Lists, Newsletters)

  • Contacts & Feedback

  • Directory & Documentation

  • eCommerce (Auction, Shopping Cart)

  • Editing

  • Multimedia

  • News Display

  • Search & Indexing



Joomla! is a modular and extensible PHP MySQL CMS (Content Management System). It is an open-source project, which is released under version 2 of the GPL license. Joomla! has fast become one of the most popular open source CMS's, which is proved by its numerous awards and massive online community.

One of the things that has made Joomla! so popular is the large number of freely and commercially available extensions which enable users to do far more than simply manage content. Extensions perform many tasks, generally classified in categories such as:

  • Ads & Affiliates

  • Calendars & Events

  • Communication (Chat Rooms, Forums, Guest Books, Mailing Lists, Newsletters)

  • Contacts & Feedback

  • Directory & Documentation

  • eCommerce (Auction, Shopping Cart)

  • Editing

  • Multimedia

  • News Display

  • Search & Indexing


Joomla! 1.5 Framework

A software framework is a reusable design for a software system (or subsystem). This is expressed as a set of abstract classes and the way their instances collaborate for a specific type of software. Software frameworks can be object-oriented designs. Although designs do not have to be implemented in an object-oriented language, they usually are. A software framework may include support programs, code libraries, a scripting language, or other software to help develop and glue together the different components of a software project. Various parts of the framework may be exposed through an application programming interface (API).


Joomla! 1.5 is implemented on a software framework that provides far greater flexibility, security, and extensibility than ever before. The Joomla! 1.5 framework is comprised of three layers or tiers. The Framework layer provides the core functionality upon which the upper layers depend, the Application layer contains applications that extend the core framework functionality, and the Extension layer adds specific functionality to the basic system.

Framework layer

The Framework layer provides core functionality through an extensive set of libraries, plugins, and the Joomla! framework.


Many, but not all, of the libraries provide Joomla! with required functionality that was originally developed and distributed by third-parties for general use, not specifically for Joomla!.

The following table details the base libraries that are included in Joomla!:





TAR file management class (

PHP License 3


Feed and vCard utilities (



DOM (Document Object Model) XML Parser (



Generic Syntax Highlighter (



Core Joomla! library



Remote login management (



Template handling (



Archive handling (



PHP Extension and Application Repository (



Generic Access Control (



Filter out unwanted PHP / Javascript / HTML tags (



Class for sending email using either sendmail, PHP mail(), or SMTP (



UTF8 and ASCII tools (



XML-RPC protocol (



RSS and Atom reader (



PDF generator that does not require additional libraries (



The framework consists of a comprehensive set of classes that provide core functionality. A list of many of the Joomla! classes can be found in the Appendices or you can browse the Joomla! Framework at Classes that make up the framework are loosely grouped into packages for easier classification and identification.

The packages that make up the framework are listed in the following table:




JApplication and related classes


Base classes


Cache classes


FTP and LDAP classes


JDatabase and related classes


Classes for creating and rendering pages


URI, Request/Response handling, and browser classes


Error handling, logging, and profiling classes


Dispatch and Event classes


Classes supporting file access


Input and output filter classes


Classes for rendering HTML


Classes for installing extensions


Language translation classes


e-mail related classes


Core Plugin classes


Configuration classes


User session handler and storage of session data classes


Site user classes


Miscellaneous classes

In addition to the packages, the framework includes the core JFactory and JVersion classes.


Plugins extend the functionality of the framework. Joomla! comes with eight core groups of plugins, each designed to handle a specific set of events.

The following table describes the different core plugin types:

Plugin Type



Authenticate users during the login process


Process content items before they are displayed


WYSIWYG editors that can be used to edit content


Editor extensions (normally additional editor buttons)


Search data when using the search component


System event listeners


Process a user when actions are performed


Create XML-RPC responses

In addition to the core plugin types, we can define our own types. Many components use their own plugins for dealing with their own events. Plugins will be discussed in detail in Chapter 7, Plugin Design.

Application layer

The Application layer extends the core JApplication class with applications designed for managing and performing specific tasks.

The JInstallation application runs when you install Joomla!. After successfully installing Joomla!, you are required to remove the installation folder, which contains the JInstallation application, before proceeding. The installation of extensions (components, modules, plugins, templates, and languages) is accomplished using the install functionality of the JAdministrator application.

The application for the Joomla! Administrator is JAdministrator. This application directs all of the backend administrative functions.

The application that is responsible for composing and delivering the frontend pages is JSite.

A Joomla! website can be administered remotely by using the XML-RPC application.

Extension layer

The Extension layer extends the Joomla! framework and applications, specifically with components, modules, templates, and languages. Plugins are also extensions but are placed in the Framework layer because they extend the framework, not applications. Joomla! is installed with a set of extensions including components for both the frontend and backend applications, templates, and modules.


Extension types and their uses

A Joomla! extension is anything that extends Joomla!'s functionality beyond the core. There are three main types of extension: components, modules, and plugins.

There are also languages and templates, but these are solely designed to modify page output, irrespective of the data being displayed. Although we will discuss the use of translation files and templates, we will not explicitly cover these two extension types in this book.

Tools, sometimes referred to as extensions, are essentially any type of extension that does not fall into the extension-type categories just described. We will not be discussing how to create tools in this book.

Extensions are distributed in archive files, which include an XML manifest file that describes the extension. It is from the manifest file that Joomla! is able to determine what type the extension is, what it is called, what files are included, and what installation procedures are required.


Components are undoubtedly the most fundamental Joomla! extensions. Whenever Joomla! is invoked, a component is always called upon. Unlike in other extensions, output created by a component is displayed in the main content area. Since components are the most fundamental extension, they are also generally the most complex.

One component of which all Joomla! administrators will be aware, is the content component. This component is used to display articles, content categories, and content sections.

In addition to outputting component data as part of an XHTML page, we can output component data as Feeds, PDF, and RAW documents.

Many components tend to include, and sometimes require, additional extensions in order for them to behave as expected. When we create our own components, it is generally good practice to add 'hooks' in our code, which will enable other extensions to easily enhance our component beyond its base functionality.


Modules are used to display small pieces of content, usually to the left, right, top, or bottom of a rendered page. There are a number of core modules with which we will be instantly familiar, for example the menu modules.


There are various types of plugins, each of which can be used differently; however, most plugins are event driven. Plugins can attach listener functions and classes to specific events that Joomla! can throw using the global event dispatcher, for example, content filtering based on an event.


Joomla! has multilingual support, which enables us to present Joomla! in many different languages. Language extensions include files that define translated strings for different parts of Joomla!.

We will discuss how to create language files and how to use translations in Chapter 2, Getting Started and later in Chapter 9, Customizing the Page.


We use templates to modify the general appearance of Joomla!. There are two types of template extension: frontend site templates and backend administrator templates.

Most Joomla! sites use custom site templates to modify the appearance of the frontend (what the end-user sees). Admin templates modify the appearance of the backend (what the administrators see); these templates are less common.

There are many websites that offer free and commercial Joomla! templates, all of which are easy to locate using a search engine.


Tools, although referred to as extensions, are very different from components, modules, and plugins. The term 'tools' is used to describe any other type of extension that can be used in conjunction with Joomla!.

Tools are not installed within Joomla!; they are generally standalone scripts or applications, which may or may not require their own form of installation.

A good example of a Joomla! tool is JSAS (Joomla! Stand Alone Server). JSAS provides an easy way to set up Joomla! installations on a Windows-based system. To learn more about JSAS please refer to


Extension Manager

Joomla! uses the Extension Manager to manage extensions that are currently installed and also to install new extensions. When we install new extensions, we use the same installation mechanism irrespective of the extension type. Joomla! automatically identifies the type of extension during the extension installation phase.



To use Joomla! and develop new extensions, a user's system must fulfill a number of basic requirements. This list details the minimum requirements:

  • MySQL 3.23 available at

  • PHP 4.3 available at

  • A web server (if using Apache, minimum version is 1.13.19, which is available at


    Precise version requirements may differ depending upon the exact version of Joomla! that is being used.

An easy way to quickly obtain and install all of these is to use XAMPP (Apache, MySQL, PHP, and Perl). This project packages all of the necessary pieces of software required to run Joomla! in one installation package. XAMPP is available for the Linux, Mac, Solaris, and Windows operating systems. To learn more about XAMPP, please refer to

Another easy way to get started with Joomla! is to use JSAS (Joomla! Stand Alone Server). JSAS enables us to quickly set up multiple Joomla! installations on a Windows-based system. To learn more about JSAS, please refer to

Joomla! itself is relatively easy to set up and, if necessary, an administration and installation guide can be found on the official Joomla! help site:


Whenever we are developing extensions for Joomla!, it is always good practice to test the extensions on multiple systems. Extensions should preferably be tested on Windows and Linux systems and tested using PHP 4 and PHP 5.


Joomla Extension Directory (JED)

The Joomla! Extension Directory ( is an official part of Joomla! and is maintained by the 'Sites and Infrastructure' working group. The directory categorizes details of third-party Joomla! extensions on which users are allowed to post reviews and ratings.

Details of extensions that are listed in JED are submitted and maintained by the extension owner or developer. A listed extension can include a category, name, description, homepage, image, license, version, download link, demonstration link, developers name, email address, and Joomla! version compatibility information.

JED is the normal place where administrators look for extensions for their Joomla! installation. Before we create new extensions, it is a good idea to investigate any similar existing extensions; JED is the perfect place to begin. If we intend to make an extension publicly available, JED is one of the best places to advertise an extension.


Development tools

There are numerous development tools available that we can use to develop Joomla! extensions. Most of these tools are not specific to Joomla!-like code and image editors or version control systems. Many can be found on the Joomla! extension directory at

When choosing an editor for modifying PHP source files, we recognize that it is important to ensure that the editor supports UTF-8 character encoding. Integrated Development Environments (IDE) such as the open source Eclipse and the commercial Adobe Dreamweaver are two of the more popular.

Open source image editors such as Gimp and Inkscape along with commercial products such as Adobe Photoshop, Illustrator, and Fireworks are frequent choices for manipulating web graphics.

An invaluable resource for developers is the developers' forge: This official site is used to host open source Joomla! projects. It provides third-party open-source Joomla! developers with free access to useful project development tools. This list details some of the tools provides us:

  • Document Manager

  • Forums

  • FRS (File Release System)

  • Mail Lists

  • News

  • SVN (Subversion)

  • Tasks

  • Tracker

  • Wiki

If we intend to create an open source Joomla! project, we should consider using to host the project, even if we do not intend to use all of the features it provides.

Coding standards

While you may not consider coding standards a tool, using a standardized format makes code easier to read and allows other developers to edit code more easily. Joomla! uses the PEAR coding standards. A complete guide to the PEAR coding standards is available at

Here is a breakdown of the more common rules:

  • Indents are four spaces: \

        // four space before me!
  • Control structures have one space between the name and first parenthesis:

    if (true) {
  • Curly braces should be used even when they are optional.

  • Functions and methods are named using the camelCase standard with a lowercase first character.

  • Functions and method declarations have no spaces between the name and first parenthesis. Parameter lists have no spaces at the ends. Parameters are separated by one space: foo($bar0, $bar1, $bar2).

  • Optional function and method parameters must be at the end of the parameter list. Optional parameter values, signified by an equals sign, are separated by spaces: function foo($bar0, $bar1, $bar2 = '').

  • Use phpDocumentor tags to comment code

  • Use include_once() and require_once() in preference to include() and require().

  • Use <?php ?> in preference to all other PHP code block delimiters.


phpDocumentor is a documentation tool that allows us to easily create documentation from PHP source code. The documentation is extracted from the source and from special comments within the source; these comments are very similar to those used by JavaDoc.

This example demonstrates how we might document a simple function:

 * Adds two integers together
 * @param int $value1 Base value
 * @param int $value2 Value to add
 * @return int Resultant value
function addition($value1, $value2)
    return ((int)$value1 + (int)$value2)

The multiline comment denotes a DocBlock. Note that it uses a double asterisk at the start. The first line is a general description of the function; this description can span more than one line. @param and @return are tags.

The @param tag is used to define a parameter in the format (the name is optional):

@param type [$name] description

The @return tag is used to define the return value in the format:

@return type description

Our initial example is telling us that the addition() function has two named integer parameters that it will add together. It will then return the resultant integer value.

When we document complex functions, we might want to provide two descriptions: a long description and a short description. This example demonstrates how we do this:

 * Does some complex processing
 * A verbose description of the function that spans more than
 * one line
 * @param int $value1 Base value
 * @param int $value2 Value to add
 * @return int Resultant vaue
function someComplexFunction($value1, $value2)
    // does some complex processing

Functions are not the only elements that can be documented. Elements that we can document include:

  • class methods

  • class variables

  • classes

  • define()

  • files

  • function declarations

  • global variables (requires use of the @global tag)

  • include()/include_once()

  • require()/require_once()

This list defines some common tags we are likely to encounter:

  • @access private|protected|public

  • @author name

  • @param type [$name] description

  • @return type description

  • @static

The DocBlocks are easy to read when they are displayed in code, but, more importantly, we can automatically create documentation from the source code. For more information about using phpDocumentor, please refer to


J!Dump allows us to output variables during development. The output is displayed in a configurable pop-up window and describes data types and object properties and methods.

J!Dump comes as two separate extensions: a component, which we use to configure the functionality of J!Dump, and a system plugin, which defines functions that we use to 'dump' data to the J!Dump pop-up. Both extensions are required in order for J!Dump to function correctly.


In order for one to use J!Dump the plugin must be published. If it is not, when we attempt to use the J!Dump functions, we will encounter fatal errors.

The most important function in J!Dump is the dump() function. We can pass a variable to this function, and it will be displayed in the pop-up. This example demonstrates how we use the dump() function:

// create example object
$object = new JObject();
$object->set('name', 'example');

// dump object to popup
dump($object, 'Example Object');

Using this will create a pop up, which looks like this:

Other functions we can use include dumpMessage(), dumpSysinfo(), dumpTemplate(), and dumpTrace().


T o get a copy of J!Dump, refer to



In this chapter, we have seen that Joomla! 1.5 is based on a comprehensive and flexible framework that is easily and securely extended through a wide variety of extensions. There are essentially six types of extensions: components, modules, plugins, languages, templates, and tools. As we have seen, each type has a very specific use. We have briefly discussed the way in which extensions of different types can be dependent upon one another.

We learned that there are many development tools available, both open source and commercial, some that are and some that are not Joomla! specific. The developers' forge is also a great resource available to Joomla! extension developers.

We also learned that the coding standards that we use are ultimately up to us, but we should consider using the same standards as those implemented by the Joomla! project. If we choose not to use these standards, we should still consider adding doctags to our classes and functions because they can greatly decrease development and debug time.

In the next chapter, we will delve deeper into the Joomla! basic design and explore how applications are created, initialized, and executed. We will also discuss the basic directory and file structure that makes up a Joomla! website. Anyone who intends to develop Joomla! extensions needs to have a solid understanding of how Joomla! works.

About the Authors

  • Chuck Lanham

    Chuck Lanham began his career as a database software engineer with Burroughs Corp. He later worked for Informix Corp. managing the database tools development group while serving as repository architect. He has founded and managed two successful software development companies, and taught college courses on database theory, data communications, and computer technologies. He has also managed the global development and deployment of leading CRM and CMS systems for many Fortune 500 companies, and managed the development and deployment of some of the largest e-commerce websites in the world.

    In 2002, Chuck left the corporate world and started a new company, Blue Water Associates. This company is located near the deep blue waters of Lake Tahoe where he designs, develops, and maintains websites for small to medium sized businesses, both within the U.S. and abroad.

    Chuck has been developing websites using Joomla! since 2007 with the release of version 1.5 and has developed several extensions for use in the websites he has designed. This is Chuck's first book as an author, although he has reviewed and edited several books and written numerous technical articles for publication.

    Browse publications by this author
  • James Kennard

    James Kennard is a computer programmer. He has worked with various PHP and MySQL applications, since 2002. He quickly discovered Mambo/Joomla! because of its flexible extension manager. James currently maintains one open-source Joomla! component, which has been translated into over fifteen languages. Moreover, he has plans to build two more open-source components. Examples of his work can be found on his personal website

    Browse publications by this author
Mastering Joomla! 1.5 Extension and Framework Development Second Edition
Unlock this book and the full library FREE for 7 days
Start now