function _submenutree_menutree_view in Submenu Tree 5
Same name and namespace in other branches
- 6 submenutree.module \_submenutree_menutree_view()
- 7.2 submenutree.module \_submenutree_menutree_view()
- 7 submenutree.module \_submenutree_menutree_view()
View the menu tree, either by poking into $node->content, or via the block functions
Parameters
$node: The node being operated upon. This is also used for configuration information.
$type: The type of menu to produce, either "submenutree" or "siblingmenutree"
$mid: The menu to be viewed
1 call to _submenutree_menutree_view()
File
- ./
submenutree.module, line 256
Code
function _submenutree_menutree_view(&$node, $type, $mid) {
// grab config from $node, depending on $type
$config_item = $type . '_title';
$title = $node->{$config_item};
$config_item = $type . '_display';
$display = intval($node->{$config_item}) & SUBMENUTREE_DISPLAY_BLOCK_MASK;
$display_in_block = intval($node->{$config_item}) & ~SUBMENUTREE_DISPLAY_BLOCK_MASK;
$config_item = $type . '_weight';
$weight = $node->{$config_item};
// tweak $title
if ($display_in_block) {
$block_title = $title;
if ($block_title == '') {
$block_title = $node->title;
}
// wipe out $title so it doesn't get passed into the theme functions
$title = null;
}
else {
if ($title == '') {
$title = null;
}
}
$menu = menu_get_menu();
$children = $menu['items'][$mid]['children'];
$output = '';
if ($display == SUBMENUTREE_DISPLAY_MENU) {
$output = theme('submenu_tree_menu', $mid, $title);
}
else {
$items = array();
// Note $v is a menu item mid, not a node nid
// Only process nonnegative mid values to build
// our list of children
foreach ($children as $k => $v) {
if ($v >= 0) {
$child_path = $menu['items'][$v]['path'];
$match = array();
$result = preg_match('!node/(.+)!', $child_path, $match);
if ($result && $match[1] > 0) {
$child = node_load(array(
'nid' => $match[1],
));
$items[] = array(
'node' => $child,
'weight' => $menu['items'][$v]['weight'],
'title' => $menu['items'][$v]['title'],
);
}
}
}
_submenutree_sort_items($items);
// Now render our links or our nodes
$links = false;
switch ($display) {
case SUBMENUTREE_DISPLAY_TITLES:
$output = theme('submenu_tree_titles', $items, $title);
break;
case SUBMENUTREE_DISPLAY_TEASERS_LINKS:
$links = true;
case SUBMENUTREE_DISPLAY_TEASERS:
$output = theme('submenu_tree_teasers', $items, $title, $links);
break;
case SUBMENUTREE_DISPLAY_FULLTEXT_LINKS:
$links = true;
case SUBMENUTREE_DISPLAY_FULLTEXT:
$output = theme('submenu_tree_fulltext', $items, $title, $links);
break;
}
}
if ($output) {
if ($display_in_block == 0) {
$node->content[$type] = array(
'#value' => $output,
'#weight' => $weight,
);
}
else {
$blocks_map = array(
'submenutree' => SUBMENUTREE_BLOCK_SUBMENU,
'siblingmenutree' => SUBMENUTREE_BLOCK_SIBLINGMENU,
);
_submenutree_set_block_content($blocks_map[$type], array(
'subject' => $block_title,
'content' => $output,
));
}
}
}