Posted by temp on March 31, 2010 at 9:55am
11 followers
| Project: | Menu block |
| Version: | 7.x-2.1 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | critical |
| Assigned: | temp |
| Status: | active |
Issue Summary
On the 6.x-2.2 version if the current menu item don't have childrens MenuBlock show items on current level.
Please add option to select style of display thit.
Thanks for module.
Comments
#1
Did this get disabled in 6.x-2.3? We upgraded due to teh XSS issue, and all of a sudden our sidebar menus all vanished beyond the first level. We used to be able to see same-level items on pages with no children. For now, we're going to have to go back to an earlier version-- I can't go through and rebuild all our menus!
#2
It sounds like you were wanting the behaviour that others thought was a bug. Is that correct? #345552: Inconsistent display of starting level set to children of active item
#3
Yes, and i will be happy if this being optionally switchable in new version.
#4
I double that!
#5
Yes, exactly.
#6
Here's the solution for this problem that works for me -- I found the difference in the file menu_block.follow.inc between ver 6.2.2 and 6.2.3
Just remove these lines 53 - 55 from the file menu_block.follow.inc:
if ($level == 'child') {$tree = array();
}
I can't remember how to write a patch file otherwise I would. Anyway, here's how I got this to work for my site.
#7
the best option would be an optional switch
#8
I second the optional switch, as it creates more consistency and thus improves user experience.
#9
I doubt this is the same issue, but I figured I'd share my idea with others that might encounter my issue. For me, if a top level menu item doesn't have any children the entire block doesn't show. Blocks need content, this is just how they work.
My menu block titles are all linked and I still need the block to show so you can click on the title regardless if you have no children. I use fgMenus on my site (http://www.juneauschools.org) to dynamically generate menus based on what
clocksblocks are present in my menu region.So I decided to modify menu_block a little to check and see if the content (menu) is empty and replace it with a UL tag with a class of "nomenu". I've also included my little recursive jQuery script that dynamically goes through each menu block and skips the "ul.nomenu" ones. Enjoy!
It would be nice if the title could always be shown or at least give the option, like they've said above.
/****************** menu_block.module (2010-05-18 Changes)
Line 322:
Commented out:
$data['content'] = menu_block_tree_output($tree, $config);
Replaced with:
$content = menu_block_tree_output($tree, $config);
$data['content'] = empty($content) ? '<ul class="nomenu"></ul>' : $content;
Reason:
Need to still show menu links even if no children. <nomenu> for fgMenus
******************/
and jQuery:
// Create fgMenusvar themeArray = new Array('blue','purple','orange','green','red');
var themeLimit = themeArray.length;
var themeCurrent = 0;
$('.block-menu_block').each(function(i){
var content = $(this).find('div.content');
if (content.length != 0) {
if($(content).find('ul.nomenu').length == 0) {
if (themeCurrent >= themeLimit) {
themeCurrent = 0;
}
var menuLink = $(this).find('h2').find('a');
var menuContent = $(this).find('div.content').find('div').html();
var menuTitle = $(menuLink).text();
menuLink.menu({
theme: themeArray[themeCurrent],
content: menuContent,
topLinkText: menuTitle
});
themeCurrent++;
}
}
});
2010-06-08: Edited
#10
Just realized that I should probably upload the fgMenu JavaScript if have seriously modified. I have fixed a lot of bugs and added a new feature (themes). Please contact me if you have any questions.
#11
Here's a simple patch for the change suggested in #6. I agree that this should be an option, but I don't have time to write the functionality.
#12
So if I update to 6.2.3 and apply this patch, will I be able to see sibling menu items? What happens if another version of MenuBlock comes out?
#13
Has this patch been rolled in to dev yet?
#14
And little extension of my feathure request,
if i disable all child of some parent menu item - menu block module (and core menu module) process them as simple child items - but if i go to this parent-child level, same level items don't showing. path above can't solve this problem (but perfectly working with simple child items), please add optionaly support of parent-child items. Thanks!
#15
I support making this an option - I'm the person who filed the original "no children, don't show siblings either" issue (and still need it that way in some circumstances) - but now I'm working on a site with a different architecture, and have found a compelling use-case for the "show siblings" scenario myself.
I think there are good reasons to make this functionality selectable and transparent, and there's clearly a need for both!
@emdalton If you apply this patch it will get written over by the next version. I don't think it's the best idea to apply it unless you've got a good maintenance log or something, or your site will break. Making it an option with the default behaviour being the current way (no menu) would stop other sites from breaking on upgrade but allow us to use the new functionality going forward if we need it.
#16
Still not rolled into the current version? :( I'll apply the patch again, but I really would like to see this changed for future releases. Is a bounty needed?
#17
I required the ability to show a menu block of "sibling menus" for some pages as well. I was able to achieve this, without patching, with the following method.
1. Create 2 menu blocks, identical.
2. For the menu block that should show siblings, instead of children, set "Starting level" to "Active menu item"
3. Check "Expand all children"
4. Set "Maximum depth" to 1 (unless you want the whole tree)
5. Optionally use some PHPfoo in the block configuration to alternate showing the appropriate menu block.
#18
Hi,
I needed to display a menu block even if there are no children -> display only the title which is set as a link.
I had to hack the module:
// Render the tree.$data = array();
$title = menu_block_get_title($config['title_link'], $config);
$data['subject_array'] = $title;
$data['subject'] = drupal_render($title);
$data['content']['#content'] = menu_block_tree_output($tree, $config);
// if (!empty($data['content']['#content'])) {
$data['content']['#theme'] = array(
'menu_block_wrapper__' . str_replace('-', '_', $config['delta']),
'menu_block_wrapper__' . str_replace('-', '_', $config['menu_name']),
'menu_block_wrapper'
);
$data['content']['#config'] = $config;
$data['content']['#delta'] = $config['delta'];
/* }
else {
$data['content'] = '';
}*/
I simply commented out the check if there is no content, and it works great.
Is it possible to add this as an option to the block config - "[] Display menu block even if there are no menu items" so something along those lines.
Thanks
Idan
#19
@arbel, yours is a separate issue. You should create a new issue for it.
#20
oh..ok thought this was the same use case.
#21
Subscribe.
The "[] Display menu block even if there are no menu items" option is needed.
Without #18 hack I saw "Notice: Trying to get property of non-object in theme_blockreference_formatter_title() (line 683 of /sites/all/modules/blockreference/blockreference.module)." when I was creating a view with Menu Blocks for menus without children.