I have a view which is exposed as a page and a block.

The view has a header defined for the page, but the header is also being displayed when called as a block. The header includes php code.

How can I check within the php code in the views header whether it is being viewed as a page or a block?

Comments

nevets’s picture

This should help

global $current_view;

if ( $current_view->build_type == 'page'  ) {
  // So something for a page
}
else if ( $current_view->build_type == 'block'  ) {
  // So something for a block
}