Book Image

Mastering Joomla! 1.5 Extension and Framework Development Second Edition

Book Image

Mastering Joomla! 1.5 Extension and Framework Development Second Edition

Overview of 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.
Table of Contents (18 chapters)
Mastering Joomla! 1.5 Extension and Framework Development
Credits
About the Author
About the Reviewer
Preface

Preface

This book will guide you through the complexities of implementing components, modules, and plugins in Joomla! 1.5. It provides useful reference material that explains many of the advanced design features and classes available in Joomla! 1.5.

Joomla! is one of the world's top open source content management systems. The main sources of the PHP MySQL application's success are its comprehensive extension libraries, which extend Joomla! far beyond content management, and it's very active forums where one can easily tap into the knowledge of other Joomla! users, administrators, and developers.

One of the most pleasurable things about working with Joomla! is the encouragement of openness and friendliness among the members of the Joomla! community. It is, without a doubt, the community that is driving the Joomla! project. The name 'Joomla!' is derived from the Swahili word 'Jumla', meaning 'all together'. The Joomla! community lends a true sense of jumla to the project.

The architecture of the latest version of Joomla! differs in many ways from previous versions. Resultantly backward-compatibility with some extensions has been broken; the race is on for developers to update their skills in order to rectify the problems and start building new extensions. Perhaps the most important of the changes is the reorganization and classification of files and classes. This change encourages but does not force developers to use the Joomla! libraries consistently between extensions.

History

Rice Studios, formerly Miro, created a closed-source CMS called 'Mambo' in the year 2000. One year later, Mambo was re-licensed under two separate licenses, one of which was open source. The open-source version became known as 'Mambo Site Server'.

In 2002 Mambo Site Server was re-branded 'Mambo Open Source' (Also referred to as MamboOS or MOS) in an attempt to differentiate the commercial and open source flavors of Mambo. All rights to Mambo Open Source were officially released into the open source community in 2003.

Mambo Open Source was extremely successful and won a large number of prestigious open-source awards.

In 2005 the commercial version of Mambo was re-branded as 'Jango'. Rice Studios, at that time still Miro, also chose to form the Mambo Foundation, a non-profit organization. The intention was to create a body that would help protect the principles of Mambo and provide a more structured working methodology.

The creation of the Mambo Foundation created a rift in the Mambo Open Source community. The creation of the Mambo Foundation was seen by many as an attempt by Rice Studios to gain control of the Mambo Open Source project.

Not long after the Mambo Foundation was created, a group, consisting mainly of the Mambo Open Source core developers, publicly announced that they intended to abandon Mambo Open Source. The group formed a non-profit organization called 'Open Source Matters'.

Open Source Matters created the Joomla! project, a guaranteed 100% open-source GPL project. The first release of Joomla! (Joomla! 1.0) was very similar to the then current release of Mambo, the majority of extensions at the time being compatible with both.

Restraints within Joomla! 1.0 led to a complete re-think of how Joomla! should be constructed. After a long development period, and two beta releases, Joomla! 1.5 was released in mid 2007.

Joomla! 1.5 is extensively different to Joomla! 1.0 and Mambo. Joomla! 1.5 introduces many new classes and implements a comprehensive framework. These changes have lead to reduced compatibility between Joomla! and Mambo.

The most notable change, for most third-party extension developers, is the introduction of the MVC (Model View Controller) design pattern in components. These changes now mean that all third-party developers tend to develop for Joomla! or Mambo, but not both. The MVC design pattern is discussed in depth in Chapter 5 , Component Design.

What this book covers

Chapter 1 , Introduction to Joomla! introduces the technology in general, covering the software framework that is the foundation for Joomla! 1.5, along with an overview of how it can be extended. It briefly discusses development tools that are readily available for use in developing Joomla! extensions.

Chapter 2 , Getting Started covers the basics of object oriented design as it applies to Joomla! The complete application process, from request to response is covered, a few core classes are introduced, and the basic Joomla! directory structure discussed.

Chapter 3 The Database deals with the database. It talks about extending the database, conventions for the database schema, and common fields. Then the focus moves on to storing data, common types of data in standard fields and dealing with multilingual requirements. We then cover querying the database and getting results.

Next, the chapter explores how to manipulate common field types. The chapter concludes with a brief description of the JTable. The JTable is used to display and edit regular two-dimensional tables of cells. The JTable has many facilities that make it possible to customize its rendering and editing but provides defaults for these features so that simple tables can be set up easily.

Chapter 4 , Extension Design covers the basics in extension design. We begin with helper classes, then cover building and using getInstance() methods. We cover the registry along with saving and loading registry values. We explain the User, Session, Browser and Assets. We finish the chapter with a discussion on the structure of components, modules, and plugins and explain extension packaging and developing XML manifest files for each.

Chapter 5 , Component Design is about designing components. It starts with the structure and a basic design of a component using the MVC design pattern. Then we learn configuring the component and its various elements and parameters.

Chapter 6 , Module Design covers designing modules. It explains standalone modules, module settings, frontend and backend modules, and modules and components working together. Then we talk about using templates.

Chapter 7 , Plugin Design deals with designing plugins. It initially deals with listeners/observers and then the various plugin groups like authentication, content editors, search, and others. Then comes loading, translating, and using plugins as libraries. Finally it deals with, plugin settings.

Chapter 8 , Rendering Output explains ways to render output and how to maintain consistency throughout. It starts with the joomla.html library and then continues to describe how to build component HTML layouts. Then it discusses how to output the backend of a component. The chapter ends with the details of itemized data and pagination.

Chapter 9 , Customizing the Page deals with customizing the page. We cover things like modifying the document and translating, along with a brief explanation of using JavaScript effects from the Mootools library, which is included in Joomla!.

Chapter 10 , APIs and Web Services explores some of the Joomla! APIs, specifically in relation to web services. We also discuss some of the more common web services and take a more in-depth look at the Yahoo! Search API. The chapter finishes by describing how we can create our own web services using plugins.

Chapter 11 , Error Handling and Security provides an introduction to handling and throwing errors, warnings, and notices. Further, it talks about building secure Joomla! extensions. It also describes a number of common mistakes made when coding with Joomla! and explains how to avoid them.

Chapter 12 , Utilities and Useful Classes explains various utilities and useful classes like dates, arrays, tree structures, and others.

The Appendices detail many of the Joomla! classes. Appendix B-H are only available as a download at https://www.packtpub.com//sites/default/files/0523_Code.zip.

Appendix A , Joomla! Core Classes provides detailed information covering the Joomla! core classes.

Appendix B , Parameters (Core Elements) provides information on how to handle the ever-useful JParameter class.

Appendix C , Site Configuration Settings describes the Joomla! configuration settings and the JRegistry class.

Appendix D , Menus and Toolbars details menus and toolbars discussing the JMenu and JPathway classes and providing complete information on toolbar buttons.

Appendix E , Joomla! HTML Library provides complete coverage of the joomla.html library along with details on the JPane class.

Appendix F , Joomla! Utility Classes covers twenty Joomla! utility classes that perform many common tasks.

Appendix G , Request and Session Handling details the Joomla! request and session handling classes, including caching and routing.

Appendix H , XML Manifest File provides detailed information on the tags available for use in XML Manifest files.

What you need for this book

To use this book effectively you need access to a Joomla! 1.5 installation. In order to run Joomla! 1.5 you need the following software: PHP 4.3 or higher (4.4.3 or greater is recommended), MySQL 3.23 or higher and Apache 1.3 or higher or an equivalent webserver.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code in text is shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

# cp /usr/src/asterisk-addons/configs/cdr_mysql.conf.sample
     /etc/asterisk/cdr_mysql.conf

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking on the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for the book

Visit https://www.packtpub.com//sites/default/files/0523_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.