Book Image

Drupal 6 Theming Cookbook

Book Image

Drupal 6 Theming Cookbook

Overview of this book

Themes are among the most powerful features that can be used to customize a website to fit your needs. The greatest strength of Drupal lies in its design, which, when done right, allows developers to customize every aspect of the site. Although it might sound easy to customize the look of your site, it's not a cakewalk to build custom themes that are easy to administer and maintain.Drupal 6 Theming Cookbook provides a plethora of recipes that enable Drupal template designers to make full use of Drupal's extensibility and style their site just the way they want it. It is a well-rounded guide, which will allow users looking to theme their Drupal sites to do so by taking full advantage of Drupal's theming system. It covers numerous aspects from creating custom themes to using the powerful CCK, Views, and Panels modules to create rich designs that are easy to administer and maintain.Structured as a collection of recipes to perform a wide variety of tasks, this book will guide readers through most important aspects of Drupal theming. It starts off with recipes dealing with the basics of Drupal's theme system: you will find recipes for solving all your problems with regions and blocks. It then moves on to advanced topics such as creating a custom theme and using it to modify the layout and style of the content that is output on a page. A substantial number of recipes are dedicated to Drupal's template system, which will provide you with a solid foundation in order to override the output of Drupal and contributed modules. Furthermore, as the combination of modules such as CCK, Views, and Panels is so widely prevalent, chapters have been dedicated for each of these modules. With this book, you'll learn to get the most out of Drupal's templating system and its modules to create rich designs for your site.
Table of Contents (18 chapters)
Drupal 6 Theming Cookbook
Credits
About the Author
About the Reviewers
Preface
Index

Allowing users to choose from multiple themes


This recipe details the steps involved in enabling users to choose which theme they wish to use when they are viewing the site. For example, users with accessibility issues might prefer to view the site using a high-contrast theme, or those viewing the site via monitors with low resolutions might prefer a theme which uses a fluid layout.

Drupal's flexible approach to themes includes the ability to allow theme-specific block arrangements. As a result, this allows us to, for example, have a separate theme for site contributors with, perhaps, an extra sidebar equipped with a contributor-specific block arrangement.

Getting ready

Since we are going to be working with multiple themes in this recipe, we will need at least two themes to have been enabled on the site. This can be done via the theme administration page at admin/build/themes (Home | Administer | Site building | Themes) as seen earlier in this chapter.

How to do it...

We can enable users to choose between the different themes which are available through the following steps:

  1. Navigate to admin/user/permissions (Home | Administer | Users | Permissions).

  2. Scroll down to the section titled system module dealing with system-level permissions.

  3. Check the box labeled Select different theme for the authenticated user role.

  4. Click on the Save permissions button to save our changes.

  5. Now, visit the My account page at the path user and click on the Edit tab at the top.

  6. Locate the newly available section titled Theme configuration.

  7. Choose the preferred theme by selecting the associated radio button as in the following screenshot:

  8. Click on the Save button at the bottom of the page to register our changes.

How it works...

Drupal saves the users' choice as a configuration setting in the database. When a page is to be displayed, Drupal notices this setting and themes the page using the specified theme instead of the site's default theme.