Can the organic group forum be provided as a tab on the group home page to provide further continuity with the group?

CommentFileSizeAuthor
#3 add_tab.patch1.23 KBdazweeja

Comments

dazweeja’s picture

This code will add a tab called Forums on the group home page for any user who has access to the forums for that group (otherwise the tab will be hidden).

Add this to og_forum_menu() in og_forum.module just after the line $items = array();

$items['node/%og_forum_group_type/forum'] = array(
    'title' => 'Forums',
    'page callback' => 'og_forum_page',
    'page arguments' => array(1),
    'access callback'   => TRUE,
    'type' => MENU_LOCAL_TASK
  );

Then add this function anywhere in the same file:

function og_forum_group_type_load($arg) {
  $node = node_load($arg);
  if (og_is_group_type($node->type)) {
     global $user;
     $tid = og_forum_get_forum_container($arg);
     if (og_forum_is_public($tid) || array_key_exists($arg, $user->og_groups) || $user->uid == 1 || user_access('administer forums'))
       return $tid;
     else
       return FALSE;
  }
  return FALSE;
}

You might have to clear the cache to get it working but otherwise works for me.

highvoltage’s picture

Thank you, dazweeja. ^_^

I'm sure many people will benefit from this code.

dazweeja’s picture

Status: Active » Needs review
StatusFileSize
new1.23 KB

OK, I've rolled a patch with this functionality for og_forum.module against 6.x-2.0-rc1.

This is only the second patch I've rolled - the first was five minutes ago - so I hope I've done it right.

gensuperman’s picture

Ok, well your previous update_patch works fine listed in this thread above, works fine, as the tab shows up successfully in the group itself.

But...

I had to deactivate the module entirely, and then reactivate it.

I also had to close out my browser and reopen it.

Then everything worked as it was intended to.

BTW, I don't mean to sound ungrateful, but, shouldn't this feature have already been included in the OG Forum to begin with? I mean, how else did you guys intend for users to find the OG Forums for each forum? I mean, if it was intended that users have to go to the main forum page to locate the group then that would have been a huge mess.

Could you please update the dev as soon as possible with this add_tab.patch feature, so that people don't think that this is the way that OG Forums is suppose to work. Because, I almost chucked the OG Forums module from my drupal created website, but thankfully someone posted about this.

dazweeja’s picture

I should have made clear that after applying this patch, the menu router will have to be rebuilt for it to take effect. Visiting /admin/build/modules after installing the patch should be sufficient to do this.

Anonymous’s picture

Version: 6.x-2.0-rc1 » 6.x-2.x-dev
Assigned: Unassigned »
Status: Needs review » Fixed

Very nice!

I'll get that committed to the development branch later today.

Best, Paul

highvoltage’s picture

whoops, wrong thread. Ignore please.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.