Associate Blocks with Forum nodes

Last modified: September 30, 2008 - 00:34

If you want show a block on all node forums, thanks to "Show block on specific pages" feature it's very simple.
First from the "Show block on specific pages" section of block settings choose "Show if the following PHP code returns" and then put the following snippet in the Pages box:

<?php
if (arg(0) == 'node' && is_numeric(arg(1))) {
 
$node = node_load(array('nid' => arg(1)));
  return
$node->type == 'forum';
}
?>

It's useful for showing showing 'Active forum topics' and 'New forum topics' blocks only on forum posts.

To reverse this change this line:
return $node->type == 'forum';
to this:
return $node->type != 'forum';

 
 

Drupal is a registered trademark of Dries Buytaert.