Search code examples
phphtmldrupaldrupal-7

Display .PHP block on /blog but not inner blog pages


I have a block which is showing on both my main blog page (/blog) and the individual blog pages themselves.

I'd like to have the block continue to show on the main blog page but not on individual blog pages.

For example the block should show on - this page but not this page.

The blocks .PHP is as follows:

<?php 
$path = isset($_GET['q']) ? $_GET['q'] : '<front>';
$link = url($path, array('absolute' => TRUE));
$findme   = 'blog';
$pos = strpos($link, $findme);
if ($pos !== false) {
  RETURN TRUE;
}
$node = node_load(arg(1));
if($node->type == 'blog') {
  return TRUE;
}
?>

Solution

  • go to /admin/structure/blocks, search for the name of the block , configure , in the Pages tab , choose "Only the listed pages" , then in the text area write the title of the main blog page