I created a Zen sub-theme (with the default starterkit folder). Now … I can't find the node id as a class of the body element. Only the (filtered) url path. But this path may change easily and will break all special css rules (which used the path class).

How can I add the node id into the body classes?


There is an older (5.x) issue about the same: http://drupal.org/node/309349

Comments

jix_’s picture

Add this to your template.php:
(Replace 'THEME' with your theme name)

/**
 * Process variables for page.tpl.php
 */
function THEME_preprocess_page(&$variables) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $nid = arg(1);
    $variables['classes'] .= " node-$nid";
  }
}
akalata’s picture

Category: feature » support
Status: Active » Closed (fixed)