Switching OG (drupal organic groups) view depending on node type

Sometimes you need to use a different drupal view when you're displaying different group types with Drupal's organic groups (OG) module, for example you might have a group thats mostly about files, and a group that's mostly about posting other items or something.

OG doesn't let you have different configurations for each node type (yet) so you can do this with a little hack, simply hit up the global $conf variable and replace it with what you need, and ensure this executes before OG does.

function mymodule_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  global $conf;
  switch ($op) {
    case 'view':
      if($node->type == 'my_other_og_type') {
        $conf['og_home_page_view'] = 'og_other_group_view ';
      }
    break;
  }
}

And here's how you ensure this execute's before OG does, you'll need to put this into a wrapper or a hook_update

update system set weight= -1 where name ='fmymodule';
0
Your rating: None