This code snippet shows you how you can create alternate theme layouts for certain pages using a preprocess function. In this function, we'll test for certain conditions and apply different CSS classes to the body tag. The following function belongs in your theme's template.php file:
<?php
function MYTHEME_preprocess_page(&$variables) {
$exploded = explode('/', $_REQUEST['q']);
if ($variables['is_front']) {
$bodyClass = 'front';
} elseif ($exploded[0]=='admin') {
$bodyClass = 'admin';
} else {
$bodyClass = 'interior';
}
$variables['bodyClass'] = $bodyClass;
}
?>Next, in your page.tpl.php file, replace your opening body tag with the following:
<body class="<?php print $bodyClass; ?>">Now, you can add CSS to change the layout of your page based off of the classes you applied to the body tag. For example:
/* hide right column for admin pages */
body.admin .column_right{ display: none; }
/* set width for right column on interior pages */
body.interior .column_right { width: 250px; }
/* set different width for right column on home page
body.front .column_right { width: 500px; }




















