I'm trying to get either the title of a page or the menu entry to be listed as a class in the body tag. I came across a posting here utilizing this code:
function THEMENAME_preprocess_html(&$vars) {
$path = drupal_get_path_alias();
$aliases = explode('/', $path);
foreach($aliases as $alias) {
$vars['classes_array'][] = drupal_clean_css_identifier($alias);
}
}
flushed all caches but my body tag still looks like:
<body class="html not-front not-logged-in no-sidebars page-node page-node- page-node-47 node-type-page section-content">
So instead of that page-node-47, I'd like to see 'about-us' or whatever the path or title of the page is. I guess the path would be a better option for a class name but I'm not picky on that matter right now.
I do have Pathauto and clean urls installed and working. And in my html.tpl, I do have this:
<body class="<?php print $classes; ?>" <?php print $attributes;?>>
$path
and$aliases
contain what you expect? The code you've got wouldn't remove thepage-node-#
class (in case you were hoping it does), it should, in theory, just add a bunch of new classes