Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Drupal 6 Theming Cookbook

You're reading from   Drupal 6 Theming Cookbook Over 100 clear step-by-step recipes to create powerful, great-looking Drupal themes

Arrow left icon
Product type Paperback
Published in Nov 2010
Publisher Packt
ISBN-13 9781847198686
Length 384 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Toc

Table of Contents (18) Chapters Close

Drupal 6 Theming Cookbook
Credits
About the Author
About the Reviewers
1. Preface
1. Drupal Theme Basics 2. Beyond the Basics FREE CHAPTER 3. Custom Themes and Zen 4. Templating Basics 5. Development and Debugging Tools 6. Advanced Templating 7. JavaScript in Themes 8. Navigation 9. Form Design 10. Customizing CCK 11. Views Theming 12. Rapid Layouts with Panels Index

Installing and enabling a theme


This recipe will cover the steps required to install and enable a downloaded theme.

Getting ready

Downloaded themes are usually in tar.gz format. These files can be extracted using archive programs such as 7-Zip (http://www.7-zip.org) as well as commercial packages such as WinZip (http://www.winzip.com) and WinRAR (http://www.rarlabs.com).

How to do it...

To install a theme, open Windows Explorer and navigate to the Drupal installation.

  1. Browse to sites/all and create a sub-folder named themes.

  2. Extract the downloaded theme into a sub-folder inside this folder. In other words, if the theme is called mytheme, the folder sites/all/themes/mytheme should contain all the files of the theme.

    In the last screenshot, we see the Acquia Marina theme's installation folder situated within sites/all/themes. Themes also occasionally contain a README.txt file which provides documentation which is worth a read-through.

    Tip

    File structure options

    In this recipe, we have chosen to use the folder sites/all/themes/mytheme to store our theme. By positioning our theme inside sites/all, we are stating that the theme is to be available to all sites using this Drupal installation. In other words, this enables multi-site setups to share modules and themes. In case we want to restrict access to the theme solely to one particular site, we would position its folder within sites/foo.example.com/themes/ where foo.example.com is the site in question.

  3. Access the Drupal site in a browser and navigate to admin/build/themes (Home | Administer | Site building | Themes).

  4. The newly installed theme should now be listed on this page. Check the associated Enabled checkbox and Default radio button.

In the last screenshot, we can see that the contributed theme Acquia Marina has been enabled and is set to be the default theme for the site. Drupal comes packaged with six core themes including Bluemarine shown in the last screenshot.

Click on Save configuration to enable the new theme and also set it as the default theme for the site.

How it works...

Drupal scans folders within sites/all/themes and, in particular, looks for files with the extension .info. This file contains information about the theme such as its name, description, version compatibility, and so on. If the theme is compatible, it is listed on the theme administration page.

A site can have multiple themes enabled. Out of these, only one can be chosen as the default theme. The default theme is, as the name suggests, the primary theme for the website. When more than one theme has been enabled, users with the select different theme permission can optionally select one of the other available options as their personal theme.

There's more...

Drupal makes it easier for us to manage our site by following preset naming conventions when it comes to the folder structure of the site.

Folder structure

Themes do not necessarily have to be placed at the root of the sites/all/themes folder. For organizational purposes, it might be useful to create sites/all/themes/contrib and sites/all/themes/custom. This will allow us to differentiate between downloaded themes and custom themes.

Tip

Since Drupal's core themes are located within the root themes folder, we might be led to believe that this might also be a good place to store our contributed or custom themes. While this will certainly work, it will prove to be a bad decision in the long run as it is never a good idea to mix core files with custom files. The chief reason for this separation is manageability—it is far easier to maintain and update Drupal when there is a clear distinction between the core installation, and contributed modules and themes.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image