I know how to add additional class by preprocess function but I need to combine it with the view. So the new custom class should be added if my view returns 0 results. It looks like I can't use hook_views_pre_build because there's no vars for page elements. Any thoughts how to achieve it?
Might be a little over-kill, but it's the first thing that comes to mind without having to build a custom view in code (which is cleaner imo). I am referencing Views 2 only, might be different in 3.
- Create an empty view page, strip it of everything if you'd like, it just needs to exist.
- In the view you are using, for the no results behavior, choose to include the empty view.
- Using the Context module, add the condition that if the empty view is shown on the page to execute. In the reactions area, add Theme HTML which will allow you to enter in your custom css class to the body tag.