In Drupal 6 (when using Views), by default, each View is wrapped in a DIV. This DIV contains a number of classes that describe the name and type of the View.
Is there anyway to output these classes in the body tag?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I can’t find a way to access the existing views classes applied to other elements, but I do what the Zen theme does, which is to use the first argument of any URL as a body class e.g. yoursite.com/case-studies would have the body class “page-case-studies”. This normally does the trick, as it is often set to be the title of the view. It can also easily be adapted/customised for specific cases.
You can achieve this with 3 lines in your THEME_preprocess_page() function, in your theme’s template.php:
For more functionality, you can just download the Zen theme, and have a look at their template.php.
Obviously make sure that your page.tpl.php is printing $body_classes. Also to use this on Drupal 6, you need to copy the drupal_html_class() function, which is also included in Zen’s template.php.