Last updated August 27, 2009. Created by Jeff Burnz on May 29, 2009.
Edited by bekasu. Log in to edit this page.

Genesis has built in support for theming site sections. For example, you may want to theme taxonomy term pages, user pages or any other site section differently.

There are three parts to this equation:

  1. Template suggestions
  2. Layout id
  3. Section classes

Template suggestions are alternate templates based on existing .tpl.php files. These suggestions are used when a specific condition is met and a matching file exists. In this instance we are going to use page.tpl.php template suggestions and our condition is Drupals internal path. See the Core templates and suggestions handbook page. You can use the the Theme developer module to easily decipher which template suggestions you should use. Theme developer is a component of the Devel module.

The layout id is a Genesis specific convention for applying a specific layout to page.tpl.php—see Setting up your layout.

Section classes are CSS selectors printed in the body element of every page except the front page. Section classes use the first part of the URL and are based on the path-alias. For example, if your URL is example.com/widgets, the section class will be class="widgets".

Putting it all together

Lets look at two examples—the user section and a taxonomy term section.

User section

Here we would have internal paths such as:

  • example.com/user/
  • example.com/user/1

So to set up a unique layout and style the user site section:

  1. The template suggestions to match both URL's is: page-user.tpl.php
  2. Set the layout using the layout id on the body element—see Setting up your layout.
  3. The section class will be class="section-user"

So, you use the template suggestion + the layout id to supply different layouts to different site sections, and the section class to style the elements in that section uniquely. For example, if you want to set a different background for the sidebars, you can use:

body.widget .sidebar {}
body.widget #sidebar-left {}
body.widget #sidebar-right {}

Taxonomy Term Sections

Here you can use taxonomy term path template suggestions using the term id, such as:

  • page-taxonomy-term-1.tpl.php (where 1 is the term id).
  • Tip: Use page-taxonomy-term.tpl.php to style all taxonomy term pages.

Set the layout id as per normal.

The get full control over taxonomy sections you need to use a path alias, otherwise the section class will be class="taxonomy" for all taxonomy term pages. A path alias is a human and search engine friendly version of the URL.

You can use the Pathauto module to write path alias's for your taxonomy terms (and all other internal paths). Alternatively you can use Drupals core Path module and write the alias manually.

Lets assume you have the path alias of "example.com/widgets" for taxnomy term 1.

  • The template suggestion is: page-taxonomy-term-1.tpl.php
  • The section class is: class="widgets"

As you can see using template suggestions, the flexible layout options of the Genesis theme and section classes gives you ultimate control over theming site sections without the need for additional modules.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.