[development] [views] Knowing the display type of a view
Steven Jones
steven.jones at computerminds.co.uk
Fri Dec 31 00:04:00 UTC 2010
Hi,
We tend to use the 'is_a' function, like so:
if (is_a($view->display_handler, 'views_plugin_display_page')) {
...
}
that way if you use a display handler that subclasses the page one,
you still get your code executed.
http://php.net/manual/en/function.is-a.php
Regards
Steven Jones
ComputerMinds ltd - Perfect Drupal Websites
Phone : 024 7666 7277
Mobile : 07702 131 576
Twitter : darthsteven
http://www.computerminds.co.uk
On 30 Dec 2010, at 15:43, Earl Miles <merlin at logrus.com> wrote:
> 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