function og_menu_block_view in Organic Groups Menu (OG Menu) 7.2
Same name and namespace in other branches
- 7.3 og_menu.module \og_menu_block_view()
Implementation of hook_block_view()
File
- ./
og_menu.module, line 206 - Integrates Menu with Organic Groups. Lots of menu forms duplication in OG context.
Code
function og_menu_block_view($delta = '') {
$block = array();
if ($delta == 'og_single_menu_block') {
$context = og_context();
$group = isset($context->gid) ? $context->gid : 0;
$menus = og_menu_get_group_menus(array(
$group,
));
$menu = array_shift($menus);
if ($menu) {
if (variable_get('og_menu_block_links', FALSE)) {
$block['subject'] = l($menu->mtitle, 'node/' . $context->etid);
}
else {
$block['subject'] = check_plain($menu->mtitle);
}
$block['content'] = menu_tree($menu->mname);
}
}
if ($delta == 'og_multi_menu_block') {
// @todo Test this!!
// Get all groups associated with the current node
$node = menu_get_object();
$gids = array();
if ($node) {
if (og_is_group_type('node', $node->type)) {
$group = og_get_group('node', $node->nid);
$gids = array(
$group->gid,
);
}
elseif (og_is_group_content_type('node', $node->type)) {
$nodegroups = og_load_multiple(og_get_entity_groups('node', $node));
foreach ($nodegroups as $ng) {
$gids[] = $ng->gid;
}
}
}
// If no group was found, fallback to the regular og_get_group_context
// function. Unfortunately, this function only returns one group.
if (empty($gids)) {
$group = og_menu_get_context();
$gids = array(
$group,
);
}
$menus = og_menu_get_group_menus($gids);
if ($node) {
$block['subject'] = check_plain($node->title);
}
$block['content'] = '';
foreach ($menus as $menu) {
$block['content'] .= '<h3>' . $menu->mtitle . '</h3>' . render(menu_tree($menu->mname));
}
}
return $block;
}