Community Documentation

Make subgroups block visible only when group has a parent or children.

Last updated June 11, 2008. Created by Amitaibu on June 5, 2008.
Log in to edit this page.

1. Go to /admin/build/block/configure/og_subgroups.
2. In Page specific visibility settings select 'Show if the following PHP code returns TRUE (PHP-mode, experts only).'
3. Paste the following code, that returns TRUE if the group has a parent or children.

<?php
   
// Only print this block if the viewed group has a parent or children.
   
if ($node = og_get_group_context()) {
     
$gid = $node->nid;
     
$top = og_subgroups_get_family($gid, 'up');
     
$bottom = og_subgroups_get_family($gid, 'down');
      if (
$top || $bottom) {
        return
TRUE;
      }
    }
?>

About this page

Drupal version
Drupal 5.x

Site Building Guide

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.