views:

175

answers:

1

drupal version is 6. just want to know where are those $body_classes comes form.

I knew in template_preprocess_page , there is a variable called 'body_classes'.

but my problem is, not all body_classes are come from preprocess page.

for instance:

I have a term named 'activities and attractions', then in my page.tpl.php, there is a class 'page-activities and attractions' in my tag. looks like taxonomy module generates a body_class, but i could find it after search seource code of taxonomy module.

+2  A: 

A module (such as taxonomy) generally does not override page template variables. Though it could be done by providing custom preprocess functions in hook_theme_registry_alter(). (See the context module for example)

The class 'page-activities-and-attractions' is most likely coming from template_preprocess_page() in includes/theme.inc on line 1894

$body_classes[] = preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-'. form_clean_id(drupal_strtolower(arg(0))));

This adds a body class for the first part of the drupal path.
For example, the path "node/1" would have a body class "page-node" and the path "taxonomy/term/1" would have a body class "page-taxonomy".

If you have a path "activities-and-attractions" (maybe from the page display of a view?) then you will get a body class "page-activities-and-attractions".

Note: This uses the internal Drupal path not url aliases. The alias "content/mypage" may really be "node/12" internally so the body class will be "page-node" not "page-content".

calebthorne