Published in: PHP
URL: http://www.ninelanterns.com.au
Similar hack to http://snipplr.com/view/5505/group-menu-block-only-shown-on-og-nodes-or-views-very-hacky/
//*********************** // 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_path = drupal_get_path_alias('node/'.$gid); // TODO: work out how to find the the 7 for each group... //$items[] = l(t('Forum post'), 'node/add/forum/7', array(), 'gids[]='.$gid); $items[] = l(t('Resource (Document)'), 'node/add/group-resource-document', array(), 'gids[]='.$gid); ?> <h2 class = "title">Add group content:</h2> <?php // 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.
