You are here

function og_subgroups_menu_tree in Subgroups for Organic groups 5.4

Same name and namespace in other branches
  1. 5 og_subgroups.module \og_subgroups_menu_tree()

Returns an HTML nested list (wrapped in a menu-class div) representing the group nodes as a tree.

Parameters

$gid: The group id.

$title: The title of the group the node belongs to.

Return value

Menu class nested list.

1 call to og_subgroups_menu_tree()
og_subgroups_block in ./og_subgroups.module
Implementation of hook_block().

File

./og_subgroups.module, line 508
Maintains subgroups hierarchy created by the orgainc groups module.

Code

function og_subgroups_menu_tree($gid, $title, $inaccessibale) {

  // Get the top level.
  $top = og_subgroups_get_all_family($gid, 'up');

  // Group might be already top-level.
  if (empty($top[0])) {
    $top[0]->gid = $gid;
    $top[0]->title = $title;
  }

  // Get children of the top level.
  $tree = og_subgroups_menu_tree_recurse($top[0]->gid, $inaccessibale);

  // We always have the top level group.
  $tree ? $output .= '<ul class="menu"><li class="expanded">' : ($output .= '<ul class="menu"><li class="leaf">');
  $output .= l($top[0]->title, 'node/' . $top[0]->gid);
  $tree ? $output .= '<ul class="menu">' . $tree . '</ul>' : NULL;
  $output .= '</ul></li>';
  return $output;
}