Contents
Preface
Acknowledgments
About the Authors
1 What Is Joomla! Development?
Developing for Joomla Is Not Difficult!
The Joomla Technical Environment
Joomla Programming: What Do You Need to Know?
Extending Joomla: Let Me Count the Ways
Open Source Means You Have Control
Overrides Let You Change What Shows on the Page
Extensions
Plugins
Modules
Components
Languages
Templates
Which Extension Type Should I Use for My Project?
Using Joomla as a Platform or Framework
Summary
2 Getting Your Workstation Ready for Joomla! Development
Requirements to Run Joomla
Apache DocumentRoot Folder
Getting Up-To-Date Instructions
Windows Platforms
Mac OS X Plaform
Linux Platforms
Default Owner for Files and Folders
Tools of the Trade
IDE versus Text Editor
Open-Source IDE Choices
Commercial IDEs
Text Editor Choices
Other Tools
Version Control Software
Automatic Builder Software (Ant and Phing)
Automated Test Programs
Summary
3 How Joomla! Works
Tour of Joomla Folders
Front End versus Back End
Cache
CLI
Components
Images
Includes
Installation
Language
Libraries
Logs
Media
Modules
Plugins
Templates
Tmp
Administrator
Joomla Platform
Web Programming versus “Normal” Programming
Maintaining the State of the Program
Controlling and Checking the Commands
Anatomy of a Joomla Execution Cycle
Load the Index.php File
Check the Execution Environment
Define the File Locations
Load the Joomla Framework
Start or Continue the Session
Route the URL
Execute the Component
Render the Page
Output the Page
Summary of Joomla Session
Naming Conventions (Conventional Wisdom?)
Global Objects
Overview of Database Tables
Note about Table Prefixes
Summary
4 Extending Joomla! with Layout Overrides
Template Basics
Template Folders and Files
Template index.php File
Positions in Templates
Template Parameters
Module Chrome
Copy Template
Template Layout Override of Latest Articles Module
Module Configuration in Sample Data: loadposition
Creating the Layout Override File
Customizing the Layout
Fixing a Problem Using the strip_tags Function
Using the JHtmlString truncate Method
Using the JHtml::_ Syntax
Change the Look of a Component: User Registration
Alternative Layouts
Adding a New Menu Item Layout
Parameter Overrides
How Do Layout Overrides Work?
Nonlayout Overrides
Module Chrome: Add New Module Style
Language Overrides: Add Translation to Our Override
Table and Model Overrides
Summary
5 Extending Joomla! with Plugins
What Is a Plugin?
How Do Plugins Work?
Naming Conventions for Plugins
Plugin Types: Where Can You Insert a Plugin?
Authentication
Captcha
Content
Editors
Editors-XTD
Extension
Search
Smart Search (Finder)
System
User
Tour of Selected Core Plugins
System: SEF
Authentication: joomla Folder
Content: joomla Folder
onBeforeCompileHead
User Registration Plugin
Update the Approval Override File
Add the XML File
Add the PHP Plugin File
Add the Language Files
Test the Plugin
Package the Plugin
Improved User Registration Plugin
Create the Plugin XML File
Create the Form XML File
Create the Plugin PHP File
Add the Language Files
Test the Plugin
Package the Plugin
Adding Parameters to Our Plugin
Using Plugins to Override Core Classes
How Plugins Are Imported
How Joomla Classes Are Loaded
Example: Override the JTableNested Class
Plugin Best Practices
Summary
6 Extending Joomla! with Modules
What Is a Module?
Modules versus Components
Tour of a Core Module
Module XML File
Main Module File
Module Helper Class
Default Layout File
Show Articles by the Current Author
Module Structure
Module XML File
Entry File: mod_joompro_articles_author.php
Helper File
Layout File: default.php
Language Files
Validating Parameters in JForm
Help File
Packaging the Module
Review of Our Module
Module Best Practices
Summary
7 Components Part I: Controllers and Models
What Is a Component?
CRUD, Get, and Post
Components Are Unique
MVC Design Pattern
Back-End Weblinks Component
Installation Files
Components Menu
Component Options (Parameters)
Helper Methods
Weblinks Component Entry Point
Weblinks Controller in Action
Weblinks Models
Weblinks Table Class
Summary
8 Components Part II: Views, JForm, and Front End
Views and the display() Method
Weblinks View
Default Layout File
WeblinksViewWeblink View
Using JForm in Weblinks
Saving the JForm Object in Memory
Modifying Forms Dynamically
Rendering the JForm
Back-End Weblinks Summary
Front-End Weblinks Component
Similar Folder Structure and MVC Pattern
Menu Item Types
Front-End Routing
Front-End News Feed View
Summary
9 Components Part III: Example Component Back End
Example Component Functional Overview
Detailed Design
Back-End Files
Subscriptions Manager: Subscriptions Screen
Default Controller
Submanager Controller and Toolbar Tasks
Manager View
Helper Class
Manager Model
Database Tables
Manager Screen Layout
Subscriptions Manager: Add and Edit
Controller Tasks
Add and Edit View
Add and Edit Model
Add and Edit Form
Table Class
Language Files
Installation and Configuration
Summary
10 Components Part IV: Example Component Front End
Files Overview
Installation XML File
Component Entry Point
Default Controller
Subscription-Category View
Menu Item XML File
Category View
Model
Category Helper File
Category Layout Files
Subscription View
Subscription Edit Controller Methods
Edit View and Form
Edit Layout
Subscribe Task
Form Model
Thank-You Layout
Language File
Packaging the Component
New Functionality: Back-End Subscriber Report
New Toolbar Button
Controller Method for New Task
New Model Class
Controller Method to Export File
Report in Action
Real-World Considerations
Summary
11 Working with Your Database
Database Overview
Creating and Modifying Tables with DDL Commands
CREATE TABLE Command
Data Types
Column Attributes
ALTER TABLE Command
DROP TABLE Command
Using phpMyAdmin
Test and Debug SQL Queries
Create DDL Scripts
Backup and Copy a Database
Using SQL Data with DML Commands
SELECT Queries
UPDATE Queries
INSERT Queries
DELETE Queries
UNION Queries
Expressions in Queries
Designing the Table Structure
Reference Tables
Key Fields and Foreign Keys
Mapping Tables
History Tables
Working with the Database Inside Joomla
Using JDatabaseQuery
Working with Query Data
Summary
12 JavaScript and MooTools in Joomla!
What Is JavaScript?
How Does JavaScript Work?
What Is MooTools?
How JavaScript and MooTools Are Used in Joomla
Built-In JavaScript Features
Calendar
Caption
Colorpicker
Form Validation
Framework
Highlighter
Keepalive
Modal
Check All and Multiselect
Noframes
Switcher
Tooltip
Tree
Uploader
Using MooTools Extensions
Using AJAX in Joomla
Using Other JavaScript Frameworks
Summary
13 Using the Joomla! Platform as an Application Framework
What Is the Joomla Platform?
Why Have a Separate Project?
What Can the Platform Be Used For?
Platform Example Programs
Set Up Platform Project
Hello World CLI Application
Web Hello WWW Application
Subscription Monitoring Example
Project Structure
Configuration File
Monitor File
Subscription Monitoring File
Running Our Monitor Program
Running CLI Programs Inside the Joomla CMS
Summary
A Crash Course on PHP and Object-Oriented Programming
PHP File Structure
PHP-Only Files
Files with PHP and HTML
PHP Syntax Basics
White Space
Important Characters
Common Operators
Arithmetic and String Concatenate
Setting Variable Types
Logical Operators
If Statements
Switch Statement
Looping Statements
Foreach Loops
For Loops
Do/While Loops
Continue Command
Alternative Syntax
Variables
Declaring variables
Variable Scope
Arrays
Working with Arrays
Strings
Constants and Current Directory
Functions and Methods
Function Structure
Function Variable Scope
Passing Variables by Reference
Including Files and File Types
Class Declaration Files
Function Declaration Files
Simple Script
Mixed Files
Including Files
Object-Oriented Programming Basics
Classes and Objects
Constructor Method
Creating Objects
Standard Class
Extends and Inheritance
Method Overriding
Public, Protected, Private Modifiers
Static Methods, Fields, and Variables
$this, self, and parent
Simple Debugging
Viewing Defined Variables
Viewing the Stack Trace
Some Advanced Code Techniques
Using || Instead of If Statements
Method Chaining
PHP Magic Methods
Variable Class and Method Names
Regular Expressions
B Joomla! Filter Types
HTML Filtering
Using Filtering in Joomla Applications
Filtering in JForm
Filtering in JRequest and JInput
Using JFilterInput Directly
C JHtml Methods
Calling JHtml Methods
Custom JHtml Classes
JHtml Class Methods
Link
Image
Stylesheet
Script
Calendar
Date
HTML Folder Classes
Batch
Behavior
Category
Content
ContentLanguage
E-mail
Form
Grid
Image
JGrid
List
Select
Sliders
String
Tabs
Glossary
Index