Problem:
You have node 1 which is aliased to content/first-node which is in the menu with link 'About'
Browsing to content/first-node results in Zen adding a body class of section-content.
I believe this section class is misleading because all it is is the alias of the current page. I would expect this class to be named page-content. I would expect a section body class to be named section-about in this case, since the current page is in the menu with the top-level link title being 'About'. By basing this assumption that everyone will set their URL aliases to always use the same first 'level' of the path for everything in the same section I think is not actually what most sites actually use. Menu trail would give us more reliable information.
This also tripped up n8tron with the unexpected behavior/results of this section class.
From http://drupalcode.org/project/zen.git/blob/refs/heads/7.x-5.x:/template....
// Classes for body element. Allows advanced theming based on context
// (home page, node of certain type, etc.)
if (!$variables['is_front']) {
// Add unique class for each page.
$path = drupal_get_path_alias($_GET['q']);
// Add unique class for each website section.
list($section, ) = explode('/', $path, 2);
$arg = explode('/', $_GET['q']);
if ($arg[0] == 'node' && isset($arg[1])) {
if ($arg[1] == 'add') {
$section = 'node-add';
}
elseif (isset($arg[2]) && is_numeric($arg[1]) && ($arg[2] == 'edit' || $arg[2] == 'delete')) {
$section = 'node-' . $arg[2];
}
}
$variables['classes_array'][] = drupal_html_class('section-' . $section);
}
Proposed solution:
Use $trail = menu_get_active_trail() and add a class based on drupal_html_class('section-' . $trail[1]['title']), since this first item in the array is 'Home'.
Comments
Comment #1
johnalbinThe section is an alias of the first part of the URL. You've aliased all your content to be under content/* so the section- class will always be section-content. Unfortunate, but I don't see how I could figure out your edge case easily. Sorry!