Block Visibility: by view and content type

You may want a block that provides some navigation for a view. I use this snippet to display the block on a view Page as well as when viewing content of a particular type. So for instance, I might have a view page which lists the current content of type 'story' called myview. On the myview Page, I also list each content's title in a block similar to a menu, so I can quickly move through the story titles. To make sure this menu only shows up when viewing the view's page and content pages which match the view's content type filtering, you can use Block's admin settings and PHP to set it up just right.

Create the block as a part of the view (or it could be its own view), set it in particular region on admin/build/block, then configure the block.

In configure, go to the bottom fieldset:

Page specific visibility settings

click the radio button:

Show if the following PHP code returns TRUE (PHP-mode, experts only).

then enter the following code, where you specify the name of the view and the content type:

<?php
// myview view or content type is story
$view_name = 'myview';
$type = 'story';
$area = arg(0);
if ($area == 'view' && arg(1) == $view_name) {
 return TRUE;
} else if ($area == 'node') {
   $node = node_load(array('nid' => arg(1)));
   if ($node->type == $type) {
     return TRUE;
   }
}
?>

In this example, assume the myview view is a teaser list of stories. So the block can be from the same view 'myview', but it is only displayed when viewing myview or 'story' content.