Views are working great for me, but I have a question about integrating my page displays into a custom theme. I have spent a week or so browsing the documentation and searching the web but haven't found the answer. So:
How do I determine the name or path of the current view and test for that in my page template (page.tpl.php) -- OR -- how can I determine the taxonomy of the nodes returned in a page display?
My problem:
The site I'm currently developing has two main sections, which are identified graphically with UI elements. I use taxonomy terms on nodes to determine which section of the site I'm in, and set the UI appropriately for the section. This all works well except for when I'm viewing a page display of a view.
I suppose I could create a particular node that I override with a theme page for these items and include a block instead... (and I may just do this), but it seems like overkill since the page displays work so nicely.
So: can I determine what the current View is from my template in a similar fashion to $node->type (e.g. $view->name or $view->path) when I don't know what view might be appearing in the template?
Comments
Comment #1
merlinofchaos commentedComment #2
flotsam commentedExcellent - thanks, merlinofchaos; I'd hoped it would be this easy.
Since I expect this will be a somewhat common question for neophytes (like myself), here's the code to get the name of the view, and a helpful block to simply output the first two levels of the view object for reference and understanding:
Other valuable resources that I found when I looked this function up specifically: