type); } // If editting a node, add a special class just for that. if (arg(2) == 'edit') { $body_class[] = 'edit'; } // Normally Drupal can give me all the classes I need for the body, but // beings I use a non-standard regions setup, we have to make our own. switch (TRUE) { case ($vars['main_supplements'] && $vars['secondary_supplements']): $body_class[] = 'sidebars'; break; case ($vars['main_supplements']): $body_class[] = 'main-sidebar'; break; case ($vars['secondary_supplements']): $body_class[] = 'secondary-sidebar'; break; default: $body_class[] = 'no-sidebars'; break; } // Now we take all those classes and ids that were created for the body // and compile them into a single variable. $vars['body_attributes'] = $body_id.' class="'.implode(' ', $body_class).'"'; } /** The following function compiles classes and ids for the individual nodes and then loaded them into a $attributes variable for the template. */ function atck_preprocess_node($vars) { $node_id = 'node-'.$vars['type'].'-'.$vars['nid']; $node_class[] = 'node'; $node_class[] = 'ntype-'.$vars['type']; if ($vars['teaser']) { $node_class[] = 'teaser'; } if (!$vars['status']) { $node_class[] = 'not-published'; } if ($vars['promote']) { $node_class[] = 'promoted-to-front'; } if ($vars['sticky']) { $node_class[] = 'sticky'; } $node_class[] = $vars['zebra']; $vars['attributes'] = 'id="'.$node_id.'" class="'.implode(' ', $node_class).'"'; } /** Comments need proper ids and classes too. This is pretty much the same process as the page and nodes. */ function atck_preprocess_comment($vars) { $comment_id = 'node-'.$vars['node']->nid.'-comment-'.$vars['comment']->cid; $comment_class[] = 'comment'; if ($vars['comment']->uid == $vars['node']->uid) { $comment_class[] = 'author'; } if ($vars['comment']->status) { $comment_class[] = 'not-published'; } if ($vars['comment']->new) { $comment_class[] = 'new'; } $comment_class[] = $vars['zebra']; $vars['attributes'] = 'id="'.$comment_id.'" class="'.implode(' ', $comment_class).'"'; } /** Set the block classes. */ function atck_preprocess_block($vars) { $block_id = 'block-'.$vars['block']->module.'-'.$vars['block']->bid; $block_class[] = 'block'; $block_class[] = 'btype-'.$vars['block']->module; $block_class[] = $vars['zebra']; $vars['attributes'] = 'id="'.$block_id.'" class="'.implode(' ', $block_class).'"'; } /** I had to wrap the profile with some extra containers to make it more themeable out of the box, so I decided some extra class and id information would also be handy. */ function atck_preprocess_user_profile($vars) { $profile_id = 'user-profile-'.$vars['account']->uid; $profile_class[] = 'user-profile'; if ($vars['is_admin']) { $profile_class[] = 'administrator'; } $profile_class[] = $vars['zebra']; $vars['attributes'] = 'id="'.$profile_id.'" class="'.implode(' ', $profile_class).'"'; } function atck_preprocess_node_add_list($vars) { $ntype_add_id = 'content-add-listing'; $ntype_add_class[] = 'content-add'; $ntype_add_class[] = 'edit'; $vars['attributes'] = 'id="'.$ntype_add_id.'" class="'.implode(' ', $ntype_add_class).'"'; $vars['node_list'] = '