By quotientix on
Hi there,
I just spend some time for solving this problem:
I wanted to add a body-class that generates from the first part of the URL (i.e. /about/page generates class="page-about").
here's the solution (found it here: http://drupal.org/node/139766):
<body class="<?php echo $body_classes; ?> <?php
if (module_exists('path')) {
$alias = drupal_get_path_alias($_GET['q']);
$class = explode('/', $alias);
print 'page-'.$class[0].'';
}
?>" id="node-id-<?php print $node->nid?>">
Additionally the scripts generates a body-ID with the node ID.
Hope that prevents someone from searching for hours ;)
Comments
jej, yes! thank u very
jej, yes!
thank u very much!
;)
For pager pages
How could I use this method to output a different body class for each page in a pager? For instance say I have a view of articles, so the first page is at /articles and the next page is at /articles?page=1 the next is /articles?page=2 and so on. How could I get the first page to have a class of "articles" and the second a class of "articles-page-1" and then "articles-page-2", etc.?
Hi Alex
Hi Alex
I don't suppose you ever came up with a solution for this?