I am unable to debug this because when I print the display object I get a memory error from the size. so with something like this I can get the display title.

function mailnow_views_pre_render(\Drupal\views\ViewExecutable $view) {
  $displayObj = $view->getDisplay();
  $displayName = $displayObj->display['display_title'];

I can get the machine name with $view->current_display == 'companies_page'

But I want to be able to get the display type for instance "Block" or "Page"


You can get it with

$plugin_id = $view->style_plugin->displayHandler->getPluginId();
| improve this answer | |
  • For clarity, that is for the active display, not in the generic sense for all displays attached to a $view. The active display isn't available in some of the early hooks (and I totally forget which ones). – mpdonadio Jun 3 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.