Book Image

Drupal 6 Performance Tips

By : T J Holowaychuk, Trevor James
Book Image

Drupal 6 Performance Tips

By: T J Holowaychuk, Trevor James

Overview of this book

<p>Drupal is one of the most respected and widely used open source content management frameworks.&nbsp; Small, medium, and large-scale websites are built using Drupal and the framework supports ecommerce, CRM, multisite and web service integrations.&nbsp; <br /><br />Once you get your Drupal site installed and up and running, you will be concerned with site performance and how fast you can make your Drupal site run.&nbsp; This book will focus on implementing performance modules and solutions to help speed up your Drupal website.<br /><br />We will look at introductory topics such as upgrading your Drupal site, maintaining your site, and enabling core Drupal page compression and caching. <br />&nbsp;<br />Then we will turn to an advanced look at some contributed modules that help speed up performance, including Development, Boost, Authcache, Advanced Cache, and the Memcache API and Integration module.<br /><br />Finally, we&rsquo;ll look at how best to implement a Drupal multisite environment and run it with high-speed performance in mind.<br /><br />This book is designed for Drupal developers and webmasters who want to increase their Drupal site&rsquo;s speed and performance.&nbsp; You will take your Drupal site to the next level by not only displaying relevant and newsworthy content, but also running a powerful and high-speed website.</p>
Table of Contents (14 chapters)
Drupal 6 Performance Tips
Credits
About the Authors
About the Reviewers
Preface

Installing the updated Zen theme files


We're going to install and upgrade the contributed Zen theme (6.x-1.0) so that we can reinstall and configure our Apollo custom theme files. The first part of this process is to install the main Zen theme folder in your /sites/all/themes directory.

  1. 1. Download the 6.x version of the Zen theme from its project page here: http://drupal.org/project/zen

  2. 2. Extract the file in your contributed modules directory on your desktop.

  3. 3. Connect to your site through FTP and browse to the /sites/all/ themes folder.

  4. 4. Upload the Zen folder.

  5. 5. Now when you refresh your themes admin list, you'll see the 6.x-1.0 versions of Zen, Zen Classic, and the Zen Themer's Starter Kit.

Upgrading your custom theme

Now we need to add our custom theme back to the site. Our theme is called 'Apollo' and we originally used the Zen Themer's Starter Kit files in Drupal 5.x to create this custom theme. Here are the steps for upgrading our custom theme to Drupal 6.x and for using the new upgraded Zen Themer's Starter Kit code base. Bear in mind that we did not make any template code edits to our original Apollo theme, so we do not need to worry about updating our new template files with our existing template code. This may be different in your specific case. Make sure to have good backups of all your existing Drupal 5.x custom theme files. We will need to copy over the CSS files from our existing Apollo theme, so we have the same CSS styles in our new 6.x site. Here are the steps:

  1. 1. Copy over your existing apollo folder using FTP into the main Zen directory in your /sites/all/modules folder.

  2. 2. Open the apollo folder on the remote side and delete the following files: template.php, theme-settings.php, and theme-settings.init.php. These are the older template files and we will replace these with the latest TPL versions—make sure you note down any specific theme override functions you may have customized or added—you can copy those out and then paste them back into the new TPL files once you add them. In our case, we did not add any specific theme overrides.

  3. 3. Now, with Drupal 6.x themes the new rule is that you need to have a .info file in your theme directory, so that the theme will show up in the modules admin list, and in order for all of your theme regions to be defined properly. You need to add an apollo.info file in the root directory of the theme. Copy the STARTERKIT.info file (from the STARTERKIT theme folder) to your local side of FTP. Open the file in WordPad, and change any reference to STARTERKIT in the file to apollo.

  1. 4. Save the file and then re-name it to apollo.info. Upload this apollo.info file back to your apollo theme directory.

  2. 5. Refresh your themes admin list and the Apollo theme will now be visible.

  3. 6. Grab the template.php file and the theme-settings.php files from the STARTERKIT folder and move those to your local site. Rename any instance of STARTERKIT in those 2 files to apollo. This includes the main function in template.php (function apollo_theme ):

/**
* Implementation of HOOK_theme().
*/
function apollo_theme(&$existing, $type, $theme, $path) {
$hooks = zen_theme($existing, $type, $theme, $path);
// Add your theme hooks like this:
/*
$hooks['hook_name_here'] = array( // Details go here );
*/
// @TODO: Needs detailed comments. Patches welcome!
return $hooks;
}
function apollo_settings($saved_settings) {
// Get the default values from the .info file.
$defaults = zen_theme_get_default_settings('apollo');
// Merge the saved variables and their default values.
$settings = array_merge($defaults, $saved_settings);
/*
* Create the form using Forms API: http://api.drupal.org/api/6
*/
  1. 7. Once those functions are renamed, upload those two PHP files to your /apollo directory.

  2. 8. Refresh your themes admin listing.

  3. 9. Enable your Apollo theme as the Default.

  1. 10. Confirm that your Garland theme is set to the default admin theme here: Administer | Site Configuration | Administration theme. You can also choose whether you want to use the Garland theme for content editing. Save configuration.

  2. 11. Congratulations! You've upgraded your custom theme to Drupal 6.x. Good work!

Cleaning up and resetting Views

The last thing to do in order to have a completely successful upgrade process is to carry out any content cleanup that's required and to reset your Views. Looking at our photo gallery content pages post-upgrade, I notice that the Lightbox2 imagecache settings were not implemented during the upgrade process. In order to use the correct Teaser and Full node display types, you may need to go back into your Photo Gallery content type and manage the Display fields configuration on your Photo file field.

The last thing you need to do is import your View code that we had exported from our Drupal 5.x site before we upgraded. Go ahead and open that .txt tile you saved and copy all the code.

  1. 1. Select all and copy code from your photo_gallery.txt file.

  2. 2. Go to your Site Building | Views admin and click on the Import button.

  3. 3. Leave the View name field blank.

  4. 4. Paste your copied View export code into the box.

  5. 5. Click on Import.

  1. 6. Check your View settings in the new Views2 interface to make sure they're translated correctly.

  2. 7. Save your View.

  3. 8. Test your View as a page and a block.

Placing your site back online

Now that you have completed the upgrade process, you can place your site back online. Browse to Administer | Site configuration | Site maintenance and check the Online radio button. Save configuration and your site will return to online status.