Search code examples
drupaldrupal-6drupal-viewsdrupal-blocks

How to display a block only on certain page view display


What is the snippet of code to make a block just show in pages generated by a certain View?

enter image description here

Using Drupal 6 with Views 2.


Solution

  • You can use views_get_page_view() to retrieve the view currently in use.

    <?php
      $display = views_get_page_view();
      $view = $display->view;
      return !empty($view) && $view->name == 'Foo';
    ?>