Posted by eternalistic on June 29, 2009 at 10:14pm
Jump to:
| Project: | Menu block |
| Version: | 6.x-2.2 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I know how to print a block in a node but how do I add a "menu block" in a node? I'm hoping this is something easy that I am just overlooking so any help is appreciated.
<?php
$block = module_invoke('block', 'block', 'view', 1);
print $block['content'];
?> I tried modifying the code that allows you to print blocks in nodes with no luck.
Thanks!
Comments
#1
Here's how to do it in Drupal 6. Simply change the "1" to the number of the block.
<?php$block = module_invoke('menu_block', 'block', 'view', '1');
print $block['content'];
?>
Namaste.
Adam Hegi
primalmedia.com
#2
That method doesn't display the title for me.
#3
Have you tried printing $block['title']?
#4
Even more straightforward, without using a separate module:
<?php$block = module_invoke('menu', 'block', 'view', 'menu-your-menu-name');
print $block['content'];
?>
#5
http://drupal.org/node/164799
#6
In Drupal 7 hook_block has changed to hook_block_op, so in order to make the above(comment #1 and #4) work you need to make some simple changes, namely changing ('block', 'op') to 'block_op'.
Example:
$block = module_invoke('menu', 'block_view', 'menu-my-menu-name');print render($block['content']);
This will work similarly to what worked in Drupal 6, as demonstrated in comment #4 above.
#7
@james:
<?php $block = module_invoke('menu', 'block_view', 'menu-main-menu'); ?>Doesnt do it for me, where do i find the menu name????? Why isnt that the block id?#8
Doesn't do it either:
<?php $block = module_invoke('menu_block', 'block_view', 1); ?>Just prints Array.
#9
Off course:
print render($block['content']);.For others:
<?php $block = module_invoke('menu_block', 'block_view', 1); ?><?php print render($block['content']); ?>
#10
No solution to this yet?
Trying the options above give an array... or prints the wrong menu.
menu-block module doesn't provide an ID number in the block admin screen.
#11
it does in the url/path
#12
@ice5nake: You can get the title with
<?php print $block['subject']; ?>