[development] [views] Knowing the display type of a view

Earl Miles merlin at logrus.com
Thu Dec 30 15:44:15 UTC 2010


On 12/30/2010 5:09 AM, Christian López Espínola wrote:
> Hi all,
> 
> I'm implementing a hook of hook_views_pre_render and I need to know if
> the current display being rendered is a page.
> 
> Is there any api in views for this?
> I'm right now using
>    substr($view->current_display, 0, 4) == 'page'
> but I wonder if there is any way more elegant.

This is probably more correct.

get_class($view->display_handler) == 'views_plugin_display_page'

More generically, there's also:
$view->display_handler->has_path() -- that gets more than just 'page'
displays, it gets 'feed' displays as well. But this could be valuable if
using something like calendar's custom page displays which aren't
specifically page displays, but act like them nonetheless.



More information about the development mailing list