/ Published in: PHP
URL: http://www.ninelanterns.com.au
Very hacky and site specific, uses ogsetgroup_context() to check if node is in a group, but also treats nodes that start with path groups/group-name-here/... as in group 'context group-name-here'
Expand |
Embed | Plain Text
//*********************** // paste this in block body //*********************** <?php // get the current group nid if we can $group_node = og_set_group_context(); $gid02 = $group_node->nid; $gid = (int)$gid02; if ($gid02 === null) { // bork: couldn't get the group nid, see Og Tracker patch for possible solution?? http://drupal.org/node/66145 // HACK: get the internal (source) url from the first part of the path with arg, expecting to find 'group/group-name' $group_url = drupal_lookup_path('source', arg(0).'/'.arg(1)); // extract the group node id, load the node and get the title $gid = $group_url_exploded[1]; $group_node = node_load($gid); } $group_title = $group_node->title; $group_path = drupal_get_path_alias('node/'.$gid); // assumes this block is built on a node that's in a group // build the links $items[] = l(t('Events'), $group_path.'/events'); $items[] = l(t('Photos'), $group_path.'/photos'); $items[] = l(t('Links'), $group_path.'/links'); $items[] = l(t('Resources'), $group_path.'/resources'); // We theme our array of links as an unordered list. ?> //*********************** // paste this in block visibility php //*********************** <?php $match = FALSE; // get the current group nid $group_node = og_set_group_context(); $gid02 = $group_node->nid; $gid = (int)$gid02; if ($gid02 === null) $gid = 0; // are we on a group page? // HACK: second param to also show this on group views generated pages // TODO: fix this crapness: (substr($_SERVER["REQUEST_URI"], 0, 7) == '/group/') global $user; // is the user a member of this group? if ($user->og_groups[$gid]['nid'] == $gid) { $match = TRUE; } } return $match; ?>
You need to login to post a comment.
