官术网_书友最值得收藏!

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:
    How to do it...
  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.

主站蜘蛛池模板: 遂平县| 高清| 九寨沟县| 三河市| 延吉市| 如东县| 中西区| 抚州市| 尼勒克县| 亚东县| 长垣县| 青冈县| 那曲县| 无为县| 临猗县| 广元市| 苏尼特左旗| 左云县| 亳州市| 遵义市| 波密县| 昌邑市| 通城县| 青龙| 行唐县| 天镇县| 甘谷县| 民和| 大庆市| 青阳县| 紫金县| 濮阳县| 阿拉善右旗| 保亭| 长岭县| 隆化县| 都江堰市| 罗田县| 监利县| 巴林右旗| 昌平区|