I have a number of View Pages that accept (OG membership from node) OG membership: Group ID as a contextual filter, where the og_menu block is not being displayed. I'm really not sure this is the best way to do this but I here is how I'm getting the og_menu single block to display on these view pages (added to the og_menu_block_view function):

    $menus = og_menu_get_group_menus(array($group));
    $menu = array_shift($menus);

    //If this is a views_page grab og context from views args
    if (!$menu) {
      $m = menu_get_item();
      if ($m['page_callback'] == 'views_page' ) {
        $view = views_get_page_view();
        $i = 0;
        foreach ($view->argument as $index => $val) {
          if ($index == 'gid') {
            $menus = og_menu_get_group_menus(array($view->args[$i]));
            $menu = array_shift($menus);
          }
          $i++;
        }
      }
    }

I can create a patch if folks think this is a valid method for getting the OG gids for a views page.

Comments

rv0’s picture

Status: Active » Closed (won't fix)

There's some ways with custom code to provide the context where needed.
Use og_context()
http://drupalcontrib.org/api/drupal/contributions!og!og_context!og_conte...

But these seems a bit to specific and maybe out of the scope of this module
e.g. what would happen when multiple groups are given as context

Setting to won't fix for now.

johnnymowmow’s picture

I'm dealing with the same problem. However, my views automatically include the name of the group in the URL. So, for example I have view for 'News' for 'Group1' - the url would be site.com/group1/news.

OG Menu shows on site.com/group1 and site.com/group1/news/node but not on the news view page.

Is it possible to render the OG Menu using the Group name as a variable? Or is there another recommended solution for displaying the OG Menu based on url within a view?

flaminhoon’s picture

I need this functionality too please. Where could I put your block of code zipymonkey?

rv0’s picture

This is not an issue with OG Menu.
Organic Groups should have a way of setting the context on views pages.

There are some issues there:
#1043840: Allow modules/pages/views/etc. to set a group context
#1781386: Context only set on primary node view page, nothing else
Check the snippet on #15 in the last one.

jaydarnell’s picture

Issue summary: View changes

As rv0 suggested in #1 - I used a php snippet in the footer of my view to set the og context based on the group entity ID passed into the view.

My snippet looks like this:

<?php
 og_context('node', node_load(!1)); 
?>

Where !1 == OG membership: Group ID input (contextual filter) - If anyone else hits this snag and needs a more detailed description of what I did please let me know and I'll be happy to share.