Created
December 11, 2012 12:43
-
-
Save cam8001/4258295 to your computer and use it in GitHub Desktop.
Using preprocess_html to add custom classes to the HTML tag. Add to a file called template.php in the 'nes' theme.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_preprocess_html(). | |
*/ | |
function nes_preprocess_html(&$variables) { | |
// Add some special classes to the HTML tag, so that we can style on a per-view basis. | |
// Get the current function handling the page. | |
$variables['menu_item'] = menu_get_item(); | |
// If it is a views.module provided page, add some classes to the html tag. | |
if ($variables['menu_item']['page_callback'] == 'views_page') { | |
// First, add a general class. | |
$class = 'page-views'; | |
$variables['classes_array'][] = $class; | |
// Then, for each argument to the view (like view name), add a specific class. | |
foreach ($variables['menu_item']['page_arguments'] as $argument) { | |
$class .= '-' . $argument; | |
$variables['classes_array'][] = $class; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment