Advanced Joomla! Dan Rahmel Apress*
Contents About the Author About the Technical Reviewer Acknowledgments Introduction xvii...xix xxi xxiii Chapter 1: Streamlining the Authoring Process 1 Setting the Editor Style Sheets 2 Setting Up an Article "Staging" Category 5 Anatomy of the Article Display Process 7 Configuring Article Display 7 Article Settings 8 Global Settings 9 Menu Settings 11 Title of the Home Page 13 Article Voting 14 Summary of Article Presentation 15 URLs and Their Challenges 16 Puzzling Out a URL 16 Examining the SEFURL 18 Configuring the Search Results Page 19 Conclusion 23 Chapter 2: Customizing Joomla with Widgets 25 Creating a Custom HTML Module 26 Adding Custom Widgets to Your Site 27 vii
Implementing the Google Calendar 28 Adding a Google Map to Your Joomla Site 31 Adding a Google Translate Web Element 33 Adding Chat to Your Site with Chatango 35 Adding the Survey Monkey Widget to Your Site 36 Adding a Related Content Module to Your Site 39 Using the PayPal Storefront 40 Summary 43 Chapter 3: Constructing a Dynamic Template 45 Designing the Template 46 Setting Goals for the Template 47 Page Types Displayed by a Template 48 Drafting the Template with a Spreadsheet 48 Implementing the Template 52 Create the Index and Template Details Files 52 Editing the Template on a Remote Server with jedit 54 Examining the Template Foundation 56 Augmenting the Basic Template 58 Creating the Head Section 58 Create the Body Section 63 Creating a Multi-Column Body 63 Using Template Parameters 68 Selecting Among Multiple CSS Files in a Single Template 72 Optimizing the Dynamic Template for Mobile, Tablet, and Other Viewing Platforms 73 Using Responsive Design for Mobile Browsers 74 General Guidelines for Handheld Templates 75 Refining the Dynamic Template 80 Avoiding Common Template Pitfalls 81 Creating a Shared Template Shell to Share Resources in a Multi-Template Site 82 Adopting Basic Style Sheet Best Practices 83 Using Page Class Suffix for Custom Styles 86 viii
Using CSS Sprites 87 Using Template Testing Tools 91 Conclusion 95 Chapter 4: Using Template Overrides 97 What a Template Override Can Do 97 Including a Custom Module in a Template Package 98 Creating a Custom Login Module 99 Including a Custom Component in a Template Package 103 Modifying the Offline page 105 Adding a Custom 404 Page 109 Conclusion 110 Chapter 5: Using JavaScript and Ajax to Dynamically Load Page Elements 111 How Ajax Changes Web Interaction 111 Dynamic Loading or Lazy Loading of Content 113 Injecting JavaScript Libraries into a Page 115 Implementing Dynamic JavaScript Loading 116 Creating the Article Injector Component 118 Creating the Directory Structure and the Installation file 119 Constructing the Component View 120 Coding the Ajax JavaScript 122 Building the Controller 124 Adding Lazy Loading of Images 127 Ajax Implementation Particulars 128 InnerText and TextContent 128 Compatibility Between JavaScript Libraries 129 Creating the Entries Returned from the Ajax Request 130 Conclusion 130 ix
Chapter 6: Joomla and Web Services 131 Web Services Overview 131 Using a Web Service with an API 132 Some Available Free API Services 135 Using Yahoo Finance with Joomla 136 Creating a Simple File Cache 136 Creating the Yahoo Finance Module 138 Adding Tweets to Your Site 140 Accessing the Twitter API 141 Formatting the Tweets Within a Module 142 Bing News API 147 Adding a Flickr Mashup 152 Conclusion 157 Chapter 7: Joomla Security Administration 159 Implementing Site Security and Server Security 159 Setting up Site Security 160 Creating a Sample Group with the Joomla User Manager 161 Protecting Against Automated Attacks 168 Ensuring Secure Cookie Settings 170 Configuring Server Security 171 Selecting the Type of Security Setup 172 Security Configuration 172 Refining Htaccess for Joomla 173 Blocking Specific IP Addresses 175 Implementing SSL on Your Server 178 Summary 183 Chapter 8: Joomla Database Administration and Configuration 185 SQL (Structured Query Language) Primer 186 Examining Some Simple Query Examples 186 Using More Complex Queries for Reporting 188
Using phpmyadmin (PMA) for Database Administration 189 Setting Up PMA 190 Using PMA to Examine the Joomla Database 192 Using the Query by Example Interface for Reports 194 Setting Up Special PMA Tables 196 Generating a PDF of the Joomla Schema 197 Using PMA to Convert Joomla Tables to InnoDB 200 Scripting the Conversion of Joomla Tables to InnoDB 201 Managing the MySQL Database Server 202 Using PMA to Back Up Your Joomla Database 202 Using PMA to Search the Entire Database for Text 203 Synchronizing Remote Databases 204 Refining the MySQL Server Configuration 207 Tracking Database Changes 208 Conclusion 210 Chapter 9: Testing a Site with ApacheBench, J Meter, and Selenium 211 Testing Overview 212 Functional Testing 212 Integration Testing 212 Regression Testing 213 Unit Testing 213 Performance Testing 213 Understanding Testing Terminology 214 Using ApacheBench for Performance Testing 215 Introducing the Selenium Suite 217 Selenium IDE 218 Selenium Core 219 Selenium Server (Formerly Selenium Remote Control or RC) 220 Selenium Grid 220 xi
Using the Selenium IDE on a Joomla Site 220 Installing Selenium IDE on Firefox 221 Recording Tests 221 Modifying the Script 224 Examining the Script Code 225 Creating and Running a Test Suite 226 Embedding JavaScript for a Dynamic Registration Test 228 Refining the Selenium Tests 231 Other Selenium IDE Options 231 Working Through Selenium's Limitations 232 Selenium Extensions 232 Adding Language Formats 232 Setting up Selenium for Flash Recordings 233 Modifying and Customizing the Selenium IDE 233 Using Selenium Core 233 Using Apache JMeter 234 Creating a Simple Load Test 235 Using the Proxy Server to Capture a Web Session 245 Editing a JMeter test 247 Conclusion 247 Chapter 10: Using Development Tools 249 Using Git for Source Code Control (SCC) 249 Advantages of Source Control 250 Version Control Is Like a Recorder of Deeds 252 Creating a Repository and Committing Files to Git 253 Some Basic SCC Terminology 255 Using Git Gui 256 Using Git to Develop Joomla Extensions 263 xii
Using Eclipse IDE and XDebug for Joomla Development 263 Install XDebug on Your Web Server 266 Configure Eclipse to Communicate with XDebug 268 Eclipse Tips and Tricks 268 Using the NetBeans IDE 269 Using the jedit for Joomla Development 269 Joomla Developer Site Overview 270 Conclusion 271 Chapter 11: Creating Joomla Menus, Articles, and Categories with PHP 273 Creating an Article Through Code 274 Creating the Main Component File 275 Building the Controller 276 Creating a Model for Data Access 280 Creating the view.html.php File 282 Creating the View Template 284 Creating a Menu Through Code 288 Some Examples of Automated Menu Creation 288 Adding the insertmenuo Method to a Controller 289 Creating a Category Through Code 290 Conclusion 291 Chapter 12: Creating Core Extensions 293 Creating the Article Historian component 293 Duplicate the Joomla Article Table 294 Adding the Trigger to Store the Old Revision 295 Creating the Article Historian component 297 Creating the Form Builder 305 Examining the Form Builder architecture 305 Creating the Form Builder administrator component 307 Creating the Form Builder Ajax component 313 Creating the Form Builder plugin 315 xiii
On-the-fly image generation with GD 320 What are the Advantages of Server-Side Chart Generation? 321 Creating a PHP Color Name List 322 Checking for GD 324 Create the cchart class 325 Overall Design of the Class 326 Creating the Color Routines 327 Creating the Text Renderer 328 Creating the Grid Renderer 328 Creating the Bar Gradient 329 Creating the Bar Renderer 330 Creating the Core Chart routine 330 Generating Sample Data 332 Creating the Joomla Component Wrapper 332 Embedding the Image 334 Conclusion 336 Chapter 13: Connecting Joomla and Facebook 337 Create a Facebook Fan Page 337 Create a Facebook App 339 Adding Facebook OG Tags 340 Examining the Basic OG Tags 341 Create an OG Tags Module 342 Using and Customizing the Facebook Like Button 346 Add the Facebook Like Button 346 Creating Multiple Like Buttons on the Same Page 347 Adding Facebook Comments 348 Understanding Facebook Insights 348 Programming to Facebook Topic Pages 350 Facebook Like Button vs. Share Button 353 Conclusion 354 xiv
Chapter 14: Development and Deployment 355 Optimizing the Development Environment 355 Using Apache Virtual Hosts to Host Multiple Sites on One Server 357 Error Display Settings and Overrides 360 Using XHProf for Execution Profiling 361 Profiling a Joomla Page Execution 363 i Optimizing the Production Environment 366 Moving the Joomla Configuration File 366 Analyzing the Server Setup 367 Setting a Server Expire for Images 370 Performing Custom Redirects 371 Setting Up a Memcache Server 371 Using the Joomla Autoloader 373 Conclusion 374 Thank You 375 Index 377