diff --git a/plugins/content_types/og_menu_pane_content_type.inc b/plugins/content_types/og_menu_pane_content_type.inc index 3f16897..563bf3e 100644 --- a/plugins/content_types/og_menu_pane_content_type.inc +++ b/plugins/content_types/og_menu_pane_content_type.inc @@ -20,9 +20,6 @@ $plugin = array( 'edit form' => 'og_menu_pane_content_type_edit_form', // Add our content type to Organic Groups category. 'category' => t('Organic groups'), - // Optionally pass in the node context. If no context is selected, - // we will try to determine the group from the args passed. - 'required context' => new ctools_context_optional(t('Node'), 'node'), ); /** @@ -30,34 +27,16 @@ $plugin = array( */ function og_menu_pane_content_type_render($subtype, $conf, $args, $context) { - // Grabs the gid from the node's group ref field (for group content nodes). - if (isset($context->data->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][0])) { - $gid = $context->data->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][0]['target_id']; + // Grab the context from Organic Groups. + $context = og_context(); + if (empty($context)) { + return null; } - // This should be true for group nodes. - elseif (isset($context->data->{OG_GROUP_FIELD})) { - $gid = $context->data->nid; - } - - // If we are using something like a view, and passing in the gid - // through the URL, then the argument should hold the gid. This also - // should be true for the group node if no context was selected. - elseif (!empty($args)) { - if (og_is_group('node', $args[0])) { - $gid = intval($args[0]); - } - else { - return FALSE; - } - } - else { - return FALSE; - } - - // Get the OG menu for the group. - $groups = array('node' => array($gid)); - $menus = og_menu_get_group_menus($groups); + // Grab our menu. + $menus = og_menu_get_group_menus(array( + $context['group_type'] => array($context['gid']), + )); $conf['og_menu_index'] = !empty($conf['og_menu_index']) ? $conf['og_menu_index'] : 1; $menu = $menus[$conf['og_menu_index'] - 1]; @@ -66,8 +45,10 @@ function og_menu_pane_content_type_render($subtype, $conf, $args, $context) { $pane->title = check_plain($menu['title']); // Link the pane title to the group if this has been set in configuration. if (isset($conf['og_menu_pane_block_links']) && $conf['og_menu_pane_block_links']) { - $pane->title_link = 'node/' . $gid; + $pane->title_link = 'node/' . $context['gid']; } + + // If menu_block is enabled, extend the display. if (module_exists('menu_block')) { // Build up an array for menu in levels. $conf['menu_name'] = $menu['menu_name']; @@ -82,6 +63,7 @@ function og_menu_pane_content_type_render($subtype, $conf, $args, $context) { $rendered_menu = menu_tree_build($conf); $pane->content = $rendered_menu['content']; } + // Render as a regular menu tree. else { $pane->content = menu_tree($menu['menu_name']); } @@ -117,6 +99,7 @@ function og_menu_pane_content_type_edit_form($form, &$form_state) { ), '#description' => t('Select the OG menu to display.'), ); + $form['level'] = array( '#type' => 'select', '#title' => t('Starting level'),