Preface

Joomla! development encompasses a wide variety of tasks. One project might be to create a single override file to change the way one page is presented. Another project might be to create an extension with multiple components, plugins, and modules.

Although no book can be all things to all people, this book provides helpful information for a variety of people, from beginners with no Joomla development experience to experienced Joomla developers who need a quick start on version 2.5.

Experienced Joomla User Who’s New to Programming

You have probably run into situations where adjusting parameters isn’t quite enough to get your site just the way you want it. Or perhaps you need an extension that isn’t quite like anything you have found in the Joomla Extensions Directory (JED). If so, this book will help you get started customizing Joomla by writing PHP code. You absolutely do NOT need to be an expert programmer to do basic Joomla development. Remember, just as Joomla was designed to let you create websites without knowing anything about PHP or MySQL, it is also designed to let you do a lot of customizing with a very modest amount of development knowledge. You will be pleasantly surprised at how much you can do with just a small amount of code and how quickly you can learn what you need to expand the flexibility and functionality of Joomla.

This book assumes that you know nothing whatsoever about PHP or MySQL programming. Everything we do is explained from the ground up. We also provide references to free resources to help you learn more about these subjects.

Experienced Web Programmer Who’s New to Joomla

In this case, you already have the basic technical knowledge to jump in; you just need to know how Joomla works. This book is organized to let you find this information quickly. Although we provide some basic PHP and MySQL information, the book is organized to make it easy for you to skip sections that you already know so you can focus on the specific information about Joomla. We also explain the design choices that were made in the overall Joomla architecture so you can understand why the program was built this way.

Need a Quick Start on Version 2.5 Development

Joomla version 1.6 was a significant change from version 1.5, especially from a developer’s point of view. Joomla versions 1.7 and 2.5 were incremental changes from 1.6. This book is based entirely on the 1.6/1.7/2.5 versions of Joomla. Where applicable, changes from version 1.5 are highlighted.

Need to Learn More about How Joomla Works and Developing Extensions

This book will provide a number of insider insights into not only how Joomla works, but also why it was designed as it was. In any large, complex package like Joomla, there are a number of design decisions that were made that have important implications for the developer. Understanding how it works and what the best practices are for Joomla development will allow you to write extensions that take full advantage of the Joomla framework and architecture and will be easy to modify and maintain going forward.

What This Book Is Not About

This book does not cover Joomla templates and design issues in general. Also, this book does not cover how to use Joomla. There are separate books that do a great job of covering these topics.

Joomla developers use a variety of tools, including PHP, SQL, XHTML, CSS, and JavaScript. Most of what we cover in this book involves writing PHP code. We do not assume that the reader already knows a lot of PHP or SQL, and we explain the code used in this book as we go along. However, this book does not try to teach the reader PHP or SQL in depth. Where appropriate, we point the reader to additional resources to supplement the information presented.

How This Book Is Organized

This book is organized from the simple to the complex. If you are an experienced Joomla developer, you can skim the first two chapters and start with Chapter 3. If you are less experienced, you will find it best to work through each chapter in order, although you may want to skip some of the sidebar information where we discuss more advanced design considerations.

This book is also designed to make it easy to use as a reference. If your initial project is a plugin, you can go straight to Chapter 5 and then fill in from prior chapters as needed, based on your experience.

This book contains a number of sidebars with supplemental information, including discussions of why Joomla works the way it does, background information on security or other important issues, and other topics that are not strictly needed to continue the flow of the book. These sidebars allow you to read or skip topics depending on your level of interest. They also make it easy to come back to something later.

Each major type of development includes a step-by-step tutorial. The authors strongly believe that the best way to understand how something works is to create a working example. Each step in the tutorial is explained so that you will understand what you are doing and why you are doing it.

The Challenge of Web Development: Too Many Things to Know!

One challenging aspect of web development—especially for newcomers—is the number of topics with which we need to be at least somewhat familiar. For example, in a typical Joomla development project, we will almost certainly work with PHP and probably with SQL queries. Working with HTML and XML is very common, and sometimes you need to be familiar with CSS and JavaScript. To set up your working environment on your PC, you will need to install and configure a web server such as Apache or Microsoft Internet Information Services (IIS) and get PHP and MySQL installed, configured, and working as well.

That’s a lot of things to know about, and we haven’t even started with Joomla yet! Each of these topics is large enough for an entire book, and no one could possibly hope to be an expert in all of them.

Fortunately, to develop programs for Joomla you do not need to be an expert in any of these topics. However, you do need to understand how they fit together and enough about each to do the job at hand.

This book does not assume that you have in-depth knowledge of any of these topics. Everything you need to know about each topic is explained as we go along. To keep this book to a manageable length, we provide the information you need to understand the material presented and then list resources that provide greater depth for a given subject.

Image

What’s New in Joomla Version 2.5?

Joomla version 1.6 was released in January 2011. It included a number of major changes from version 1.5. Starting with version 1.6, the Joomla project committed to releasing a new version every six months and a new long-term-support (LTS) release every 18 months. As a result, version 1.7 was released in July 2011 and version 2.5 in January 2012.

Why did the number skip from 1.7 to 2.5? This was done so that all LTS releases would be numbered as X.5, where X is the major release. Version 1.5 was an LTS release. Version 2.5 is the LTS release for the 1.6/1.7/2.5 series. Version 3.5 (due in July 2013) will be the next LTS release, after versions 3.0 (July 2012) and 3.1 (January 2013).

This book covers Joomla version 2.5. Since a major goal of this book is to help developers with the transition from version 1.5, we highlight areas where things are done differently for version 2.5.

Version 1.6 was a major upgrade that incorporated a number of significant changes. Version 1.7 contained some smaller new features, and 2.5 more additional features. The most important of these are listed here.

Access Control List System

Version 1.6 added a new access control list (ACL) system that allows site administrators to fine-tune what different groups of users are allowed to do in the front and back end of Joomla. This system is extremely powerful and flexible, and it is easy for third-party developers to hook into. We explain how the system works and what you need to know to take full advantage of it in your projects.

User-Defined Category Levels (and No More Sections!)

Prior Joomla versions had two fixed levels for articles called section and category. In version 1.6, sections are eliminated. Instead, you can create your own category structure. For example, you can have a simple category structure with just one level, or you can have categories, subcategories, sub-subcategories, and so on—up to any (reasonable) depth. This allows for simpler and more complex structures than were available before.

This feature is designed to make it easy for developers to add this same feature to their own extensions.

JForm

In version 1.5, you could easily create screens for setting parameters using the JParameter class. In version 1.6, this is replaced with a new class called JForm, which makes it easier to create powerful forms for your applications. JForm gives you a great combination of flexibility and ease of use when you need to create data entry forms in Joomla. All the back-end screens for Joomla were rewritten for version 1.6 using JForm.

One impact of this change is that the format for XML files for extensions has changed. This is discussed in each of the chapters about writing extensions.

JTableNested

JTableNested is a new base class for the Category, Menu, and other tables that allow for nested levels of items. It provides an API to make it easy for developers to create tables based on nested sets in our code.

JDatabaseQuery

JDatabaseQuery is a new class that makes it easier to write complex SQL queries in Joomla. It gives you an application programming interface (API) to build SQL queries in a logical manner, based on the logical structure of the query. This makes it much easier to write and maintain complex SQL queries. You don’t have to use this new class in your SQL queries, but we hope you will agree that it is a better way to work with SQL queries in Joomla.

PHP Version 5.2

Joomla version 1.5 had to be compatible with PHP version 4. This limited the extent to which Joomla could take advantage of the object-oriented programming (OOP) improvements made to PHP in version 5.0 and 5.2.

Starting with Joomla version 1.6, PHP version 5.2 or higher is required. This allows version 1.6 to use static and abstract classes. In addition, in PHP 5.2, all objects are passed by reference by default, which means that the &= (assigned by reference) operator is no longer needed in most cases.

The newer PHP also allows Joomla to use the native SimpleXML class for parsing XML files and to use the native DateTime class. So JXMLElement and JDate have been modified and simplified accordingly.

MySQL Version 5.0.4

Joomla 1.6 requires MySQL version 5.0.4 or higher. This version of MySQL provides a number of enhancements, including stored procedures, triggers, views, and a number of performance improvements. It also allows for large columns of type varchar.

Language File Format

Joomla version 1.6 introduces a major change to the language file format. Previously, Joomla used a proprietary format. Starting in version 1.6, that was changed to the standard PHP .ini file format. This allows Joomla to use the standard PHP parse_ini_file command, which is much faster and simpler than the old proprietary method.

This does, however, require that language files be reformatted to the new standard.

One-Click Update

Version 2.5 allows your Joomla website to be updated automatically. The site administrator is notified whenever an update is available either for the core Joomla files or for any extension used on the site (as long as the extension developer supports this feature). The site can be updated simply by clicking on the Update button. Instructions for setting up this capability for extensions is discussed in the companion website, http://joomlaprogrammingbook.com.

Improved MVC

The model-view-controller (MVC) design pattern was improved for version 1.6. This included using the pattern more consistently in the back end and improving code reuse by moving code to standard library classes where possible. We discuss Joomla’s MVC implementation in detail in Chapters 710.

Support of Other Databases

Version 2.5 introduced support for other databases (besides MySQL), starting with Microsoft SQL Server. Support for PostgreSQL is also under development and is expected to be added soon.

Improved Search

Version 2.5 introduced Smart Search. This is a completely new search engine that greatly improves the quality and accuracy of full-text searching of the content in a Joomla website.

Companion Website

The authors have set up a website at http://joomlaprogrammingbook.com where we have additional information about Joomla programming. We also have zip archive files with the code from the book, organized by chapter.

This website will be kept up to date with new information about Joomla versions and will list any corrections to the print version of the book.

Welcome to Joomla Development

Joomla developers come from all backgrounds and have varied amounts of experience in software development. Many started with HTML websites and have learned more about web programming as they worked with Joomla. Some have degrees in computer science; some come from a background in web design. Others just learned by using Joomla, reading, and working with others.

The Joomla development community strives to be open and welcoming to new people, including those with little or no programming experience or formal technical education. A number of resources are available for reading about various topics and asking questions. Two of the most important ones are as follows:

http://developer.joomla.org is the Joomla site exclusively devoted to Joomla development. This website includes information about the current state of the project and the latest development news. It also includes links to the Google groups where Joomla development issues are discussed.

http://docs.joomla.org/Developers is the entry point for all developer-related, online documentation in the Joomla wiki site. Note that this site is a wiki that is maintained by the community. Anyone can register and update or add information to the wiki.

The authors hope this book makes it easier for people to learn to develop programs for Joomla, regardless of their prior level of experience.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset