Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.5
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 May 2009 at 08:43 UTC
Updated:
23 Nov 2010 at 14:31 UTC
global $current_view;
print $current_view;
the above code does not work for me. i have tested it with all the template files (node.tpl, page.tpl, etc.) i am using drupal 6.12 and views 6.x-2.5, has something changed drastically here? it used to work with previous versions of drupal, though. i want to create custom template files based on view. (specifically, page/block as per view name.)
Comments
Comment #1
dawehnerthis was in drupal5
you should use now
but just print $view will not work
Comment #2
mesh commentedthanks dereine,
it returns a views object. how do i extract the display being used currently? (page, block etc?)
Comment #3
mesh commenteddereine,
$view->current_display does it, right? but again, it gives me names like page_1, block_1 etc. instead of the display name itself.. any suggestion?
Comment #4
merlinofchaos commented$view->display[] contains the entire displays by key. $view->display_handler contains the object controlling the display.
Comment #5
mesh commentedthank you merlinofchaos,
but you confused me further. yes, the display handler contains the object controlling the display. upon print_r it shows a complete list of all displays for that view. i want to find out which display of all those (page, block etc) is deployed currently. this will help switching the template code accordingly. this is what i figured out -
returns name of the current view and,
returns the display being used.
Comment #7
knalstaaf commentedIn order to see the actual name you have to add the print-rule (if that's your question):
It only works when it's being used in the Views template-file.