function menu_block_split_block in Menu Block Split 5
Same name and namespace in other branches
- 5.2 menu_block_split.module \menu_block_split_block()
- 6.2 menu_block_split.module \menu_block_split_block()
- 6 menu_block_split.module \menu_block_split_block()
File
- ./
menu_block_split.module, line 79 - Allow to have an splitted menu within two blocks
Code
function menu_block_split_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
for ($i = 1; $i <= variable_get('mbs_howmany', 1); $i++) {
$mid = variable_get('mbs_' . $i, '');
$item = menu_get_item($mid);
$blocks[$i]['info'] = 'mbs-' . $item['title'] . '-1st';
}
$blocks[1000]['info'] = 'mbs-2nd';
return $blocks;
}
else {
if ($op == 'configure' && $delta == 0) {
}
else {
if ($op == 'save' && $delta == 0) {
}
else {
if ($op == 'view') {
switch ($delta) {
case $delta < 1000:
$block['subject'] = variable_get('mbstitle_' . $delta, '');
$block['content'] = theme(menu_block_split_first_level_menu, variable_get('mbs_' . $delta, ''));
break;
case 1000:
$mid = menu_get_active_nontask_item();
for ($i = 1; $i <= variable_get('mbs_howmany', 1); $i++) {
$pid = variable_get('mbs_' . $i, '');
if (menu_block_split_is_child($pid, $mid)) {
if (menu_block_split_is_first_level($mid)) {
$item = menu_get_item($mid);
$block['subject'] = $item['title'];
$block['content'] = theme('menu_tree', $mid);
}
else {
$menu = menu_get_menu();
$menu = $menu['visible'];
foreach ($menu as $key => $value) {
if (menu_in_active_trail($key) && menu_block_split_is_first_level($key)) {
$block['subject'] = menu_block_split_block_title($key, false);
$block['content'] = theme('menu_tree', $key);
}
}
}
}
}
}
return $block;
}
}
}
}
}