function _submenutree_menutree_view in Submenu Tree 7
Same name and namespace in other branches
- 5 submenutree.module \_submenutree_menutree_view()
- 6 submenutree.module \_submenutree_menutree_view()
- 7.2 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"
$tree: A fragment of a menu tree to be viewed
1 call to _submenutree_menutree_view()
- submenutree_node_view in ./
submenutree.module - Implements hook_node_view().
File
- ./
submenutree.module, line 333 - Submenu Tree
Code
function _submenutree_menutree_view($node, $type, $tree) {
// grab config from $node, depending on $type
$config_item = $type . '_title';
$title = check_plain($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;
}
}
$output = '';
if ($display == SUBMENUTREE_DISPLAY_MENU) {
$output = theme('submenu_tree_menu', array(
'tree' => $tree,
'title' => $title,
));
}
else {
$items = array();
foreach ($tree as $k => $v) {
// Check that this is a node view
if (empty($v['link']['hidden']) && strpos($v['link']['href'], 'node/') === 0) {
$nid = substr($v['link']['href'], 5);
$child = node_load($nid);
$items[] = array(
'node' => $child,
'weight' => $v['link']['weight'],
'title' => check_plain($v['link']['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', array(
'items' => $items,
'title' => $title,
));
break;
case SUBMENUTREE_DISPLAY_TEASERS_LINKS:
$links = true;
case SUBMENUTREE_DISPLAY_TEASERS:
$output = theme('submenu_tree_teasers', array(
'items' => $items,
'title' => $title,
'links' => $links,
));
break;
case SUBMENUTREE_DISPLAY_FULLTEXT_LINKS:
$links = true;
case SUBMENUTREE_DISPLAY_FULLTEXT:
$output = theme('submenu_tree_fulltext', array(
'items' => $items,
'title' => $title,
'links' => $links,
));
break;
}
}
if ($output) {
if ($display_in_block == 0) {
$node->content[$type] = array(
'#markup' => $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,
));
}
}
}