Preface

This book will give you a step-by-step introduction with practical examples of how to develop plugins, modules, and components for Joomla! 3. It may also be useful for people who wish to make minor modifications to existing components, rather than creating their own extensions from scratch.

Joomla! is one of the world's most popular open source content management systems (CMS), which currently powers approximately 2.7 percent of the websites on the Internet. Joomla! has been downloaded over 35 million times, and has thousands of add-on extensions (apps). Joomla! 3 is the first major CMS to be mobile friendly by default.

Unlike the other two popular open source CMS projects, Joomla! is completely community driven; there is no controlling company or paid staff. Joomla! uses object oriented principles, and is database agnostic. Joomla! is the best mix of functionality, extensibility, and user friendliness.

Developing extensions for Joomla! allows you to harness the full power of Joomla! and build some really great websites and applications. This book is going to give you all the knowledge you need to get started with Joomla! extension development, with lots of practical examples that you can follow along with and learn by doing.

There are many ways that you can get involved with the Joomla! community and contribute to make it better. There is no minimum time commitment; you can contribute as much or as little as you like.

Most major cities have a Joomla! User Group (JUG) that meets regularly to share Joomla! knowledge, which I encourage you to join. Many JUG groups run annual Joomla!Day conferences, which are definitely worth going to, and are a great opportunity to network and pick up some great tips. You can find out about JUG groups and Joomla!Day events at http://events.joomla.org/.

Joining the bug squad is a great way for developers to contribute, and it is also a good place to learn more about the Joomla! codebase and to improve your coding skills. You don't even need to contribute code to be part of the bug squad; you can test other people's patches and make sure they work, and at the same time get a better understanding of how it all works. The Joomla! Developer Network site has links to the issue tracker and other information that will help you get started http://developer.joomla.org/.

Got a few spare minutes? Jump onto the Joomla! forums and answer a few questions; there are many people who are just starting out with Joomla! and could do with a helping hand http://forum.joomla.org/.

Developing extensions is a great way to encourage the use of Joomla! and your individual effort can make a big difference. I know many people who made the decision to use Joomla! due to the availability of just one specific third-party extension that solved the problem they had in an efficient and cost-effective way. So I encourage you to get involved full stop I'm sure you'll have fun along the way and make some new friends at the same time.

What this book covers

Chapter 1, Before you Start, contains some information that you should know before you start developing Joomla! extensions. It will give you a brief introduction to the extension types in Joomla! as well as highlight some new features of Joomla! 3 compared with previous versions. We will also look at licensing, business models, and coding standards, and touch on upgrading Joomla! 2.5 components to Joomla! 3.

Chapter 2, Getting Started with Plugin Development, is where you will create your first plugin for Joomla!. This chapter will introduce some basic concepts such as how the installation XML file works and how to create an installable extension for Joomla!. We will use this plugin later in conjunction with our component.

Chapter 3, Getting Started with Module Development, covers module development, both frontend and backend. We will also look at template overrides and alternative layouts, and how to make your module responsive using Bootstrap.

Chapter 4, Getting Started with Component Development, covers component development and by the end of this chapter you will have built a very simple component that we will make more complex in the following three chapters. It also explores the numerous JForm field types.

Chapter 5, Backend Component Development – Part 1, continues development of our component, but focusing on the backend. Specifically you will learn how to add columns to your view, implement drag and drop ordering, add toolbar buttons and view filters.

Chapter 6, Backend Component Development – Part 2, is where you will finish the backend of your component. You will learn about pagination, submenus, ACL, and how to make your component support multiple database types.

Chapter 7, Frontend Component Development, covers the development of the frontend of your component. You will learn how to add CSS files, menu item parameters, and how to translate your component. We will also look at how your component can interact with other extensions such as Captcha and a third-party comments component.

Chapter 8, Security – Avoiding Common Vulnerabilities, contains some hands-on ethical hacking to teach you about common vulnerabilities and how to avoid them in your extensions.

Chapter 9, Packing Everything Together, covers how you can prepare your extensions for distribution, as well as managing changes. It also shows how you could set up an update server, and some tips for getting listed on the Joomla! Extension Directory.

Chapter 10, Extending your Component with Plugins and Modules, contains a few plugins and modules that extend the functionality of your component, including a smart search plugin. We will also take a look at the new tags feature in Joomla! 3.1 and how you can integrate this into your component.

What you need for this book

You will need Joomla! 3 installed either locally or on a server you have access to. Ideally you should have a local development environment, which should have a web server, PHP and MySQL, with Joomla! 3 installed. For Joomla! 3 you will need PHP Version 5.3.1 or greater and MySQL Version 5.1 or greater. For more information on Joomla!'s technical requirements, visit http://www.joomla.org/technical-requirements.html.

For the Multi-database support section in Chapter 6, Backend Component Development – Part 2, you will need Microsoft SQL Server 2008 or greater. You can use the free Express edition; there is no need to have the purchased version.

Who this book is for

This book is for developers who want to create their own Joomla! extensions. It is assumed you will have some basic PHP, HTML, and CSS knowledge, but you don't need any prior Joomla! programming experience.

Although this book starts out from scratch, it builds up to some more advanced topics that will interest experienced developers, such as integrating a third-party comments extension, so it is not just for beginners.

This book may also be useful to people that just want to make minor customizations to existing Joomla! extensions and build on the work of others in the open source spirit.

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 words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Then you can load the code into your component's main php file."

A block of code is set as follows:

if (x == y)
{
  //do something
}

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

<extension
    version="3.0"
 type="plugin"
    group="content"
    method="upgrade">

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: "Navigate to Extensions | Extension Manager, and select the Discover view at the left side".

Note

Warnings or important notes appear in a box like this.

Tip

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 topic that you have expertise in and you are interested in either writing or contributing to a book, 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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

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/submit-errata, selecting your book, clicking on the errata submission form 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.