Basic ideas behind dynamic theming
In addition to creating templates that are displayed conditionally, the Drupal also provide us to apply CSS for specific conditions on any given page.
$classes
this variable aid dynamic CSS styling. Conditional style is used to mange the one, two, or three columns style, or to behave different when logged in as authenticated users.
- Before Drupal 6
$layout
was used
- In Drupal 6
$body_classes
- And Drupal 7 Supports
$classes
By default $classes is included with body tag in html.tpL.php file that's mean $classes is available to all templates.
Below are the dynamic classes available by default in Drupal 7
.front/*front page*/
.not-front /*not front page*/
.not-logged-in /*not logged in*/
.logged-in /*logged in*/
.node-type-[name of type] /*node visible*/
.page-[page type] /*page visible*/
.two-sidebars /*two sidebars*/
.sidebar-left /*left sidebar visible*/
.sidebar-right /*right sidebar visible*/
.one-sidebar /*one sidebar*/
.no-sidebar /*no sidebars*/
For example
<body class="html front not-logged-in one-sidebar sidebar-first page-node">
<body class="html front logged-in one-sidebar sidebar-first page-node">s
<li class="<?php print $classes; ?>"></pre> /*Calling $classes*/
$classes play vital role in creating dynamic theming.
Adding new variables to $classes
In your template.php file
<?php function themename_preprocess_node(&$vars) { $vars['classes_array'][] = ''} ?>
now this variable will be available to all template
Thanks
0 Comment(s)