I will post this to views as well, but I think the solution is likely ultimately regarding the template_proprocess_page function inside includes/theme.inc.

The basic scenario is as follows: a site has a view presented as a page located at "example.com/press". The CSS for the theme styles this page using the "page-press" body class. Through the menu system this page is given several children, also nodes, each located at "press/*", e.g. "press/releases", "press/resources", etc. Because arg(0) for each of these views pages resolves to "press" the body class "page-press" is added to all children of the page press as well as the page press itself. I believe that "section-press" is the proper class (this is added as well).

The code responsible for this is on line 1803 of theme.inc as of the current 6.4 build (updated via CVS 9/15), pasted below. As noted in the comments, the intent of this line is to add the page type to the body classes, however because not all paths are of the type
/ this does not have the intended effect in all cases.

My initial reaction is that some more specific handling should be added to this function to check that arg(0) matches some set of known roots or module names prior to adding the arg(0)-based body class.

If this is not the case, are there conventions site developers or module developers should follow to avoid scenarios such as the one above?

  // Add arg(0) to make it possible to theme the page depending on the current page
  // type (e.g. node, admin, user, etc.). To avoid illegal characters in the class,
  // we're removing everything disallowed. We are not using 'a-z' as that might leave
  // in certain international characters (e.g. German umlauts).
  $body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));

Thank you,

Ethan

Comments

dpearcefl’s picture

Is this still an issue using current Drupal 6 and Views2?

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.