drupalorganic-groups

Drupal - Block visibility


I am using the below code in the block visibilty settings, to only show the block if the user is a member, and not the admin.

What can I add to further filter it down to type of Organic Group Node.

i.o.w Only display if the currnt group being viewed = Organic Group Node Type X

<?php
  $in_og = FALSE;
if (module_exists('og')){
  $in_og = FALSE;
  $group_node = og_get_group_context();
  $gid02 = $group_node->nid;
  $gid = (int)$gid02;
  if ($gid02 == null) $gid = 0; 
  if (og_is_group_member($group_node)) $in_og = TRUE;
  if (og_is_group_admin($group_node)) $in_og = FALSE;
  if ($gid == 0) $in_og = FALSE;
}
return $in_og;

thanks


Solution

  • Maybe something like"

    <?php
        $in_og = FALSE;
        $right_group = FALSE;
        if (module_exists('og')) {
            // get OG $group_node
            $group_node = og_get_group_context();
            if ($group_node->type == 'type-x') {
                // we have the correct group type
                $right_group = TRUE;
            }
            $gid = $group_node->nid;
            if (og_is_group_member($group_node)) {
                // show to members
                $in_og = TRUE;
            }
            if (og_is_group_admin($group_node)) {
                // hide from admins
                $in_og = FALSE;
            }
        }
        return $in_og && $right_group;
    ?>