By sovietfunk on
I need to detect whether the current page is a View, and just can't find any variables or functions which i can use in my template.php or page.tpl.php.
For example, i need to append a class or id ("views vtype-currentview") to $body_classes in my Zen template. Classes like this are available in the divs enclosing the view content, but i need them at a higher level too.
Comments
Solution
OK, hacked it myself. I made a simple function which i call in template.php and feed to the body_classes array if it returns a value. So now I have an additional class of
.views-VIEWNAMEto customize layouts and backgrounds with. I have only tested it with clean-urls and properly set paths. But I still can't believe that there isn't a function somewhere in views.module that does this. The global $current_view called in page.tpl.php only returns my calendar block view. Ah, well.Here's the function:
This is working with dirty
This is working with dirty urls also. Thanks for this.
---
Robert Garrigos
Professional site: robert.garrigos.cat
Catalan Drupal Users Group: drupal.cat
Allows me to find if the current page is a view
Works great for me
For drupal 6
For D6 try this - http://drupal.org/node/216065#comment-2194162