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

Chapter 3. Custom Themes and Zen

We will be covering the following recipes in this chapter:

  • Clearing the theme registry
  • Creating a theme from scratch
  • Creating myzen, a Zen-based theme
  • Choosing a CSS layout for myzen
  • Overriding Zen template files with myzen
  • Adding a custom region to myzen
  • Adding a background image to the theme
  • Adding a conditional stylesheet in Zen
  • Modifying myzen's theme settings

Introduction

While, as detailed in the previous chapter, sub-themes of core and contributed themes are convenient and efficient in modifying and reusing elements of their base themes, circumstances often require a completely unique approach specific to our site. Custom themes are the solution for websites which demand a fresh look, using complex layouts, or need so much customization that it would be prudent to start with a clean slate.

Custom themes are the equivalent of handcrafted pieces of art as the themer controls every piece of the puzzle from a design or implementational point of view. This includes setting up the theme using .info files, choosing the layout, implementing it in a page template, adding regions, styling nodes using node templates, blocks using block templates, and so on. But over time, developers have identified a list of common tasks, characteristic layouts, and file and folder hierarchies which are logical, efficient, and promote reuse. This has evolved into what have been dubbed starter themes, themes upon which custom themes are built, usually as sub-themes.

The most popular starter theme for Drupal is Zen. As advertised on its project page, the Zen theme is a flexible standards-compliant and semantically correct XHTML theme that can be highly modified through CSS and an enhanced version of Drupal's template system. It is designed in modular fashion making it straightforward to change layouts, override templates and theme functions, and to add or remove features. Additionally, the Zen theme comes with extensive documentation within each file which make things all the more convenient.

With respect to CSS, Zen maintains a number of well documented CSS files segregated by functionality or location. For example, layout rules are contained within a dedicated layout.css (or similar) file and page backgrounds are styled within page-backgrounds.css and so on. This makes it convenient when it comes to managing and tracking code changes.

In addition to the standard files we have encountered while customizing themes in earlier chapters, a Zen-based theme contains the following file and folder structure:



File/folder name           Purpose
template.php           A file where theme overrides and other theme and engine-related code is placed.
theme-settings.php           A file where settings particular to a theme can be placed. These settings are usually exposed on the theme's configuration page.
css/           A folder to store stylesheets.
images/           A folder to store images used in the theme.
images-source/           The folder where the source files for the optimized images in the images folder are available.
js/           A folder to store JavaScript files.
templates/           A folder where tpl.php template files are to be placed.

There are a number of other starter themes available on drupal.org. Some of the more popular ones include Fusion (http://drupal.org/project/fusion), Blueprint (http://drupal.org/project/blueprint), Ninesixty (http://drupal.org/project/ninesixty), and Adaptivetheme (http://drupal.org/project/adaptivetheme). We will be looking only at the Zen starter theme in this book.

主站蜘蛛池模板: 淮阳县| 巩义市| 逊克县| 方正县| 池州市| 霞浦县| 漳浦县| 长海县| 五指山市| 涪陵区| 修文县| 龙里县| 凤阳县| 桦川县| 个旧市| 铁岭市| 阿拉善盟| 全椒县| 扎兰屯市| 霍林郭勒市| 维西| 鹿泉市| 绍兴市| 江山市| 温宿县| 吉木萨尔县| 云和县| 延庆县| 祁门县| 兰西县| 云南省| 淳安县| 息烽县| 保定市| 汝城县| 平南县| 定襄县| 阿鲁科尔沁旗| 鄂托克前旗| 文成县| 吉木萨尔县|