Community Documentation

Associate Blocks with Forum nodes

Last updated September 30, 2008. Created by Mamouri on March 30, 2006.
Edited by add1sun, sepeck, Heine. Log in to edit this page.

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';

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 4.7.x, Drupal 5.x, Drupal 6.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.