• In admin/structure/menu I created a menu
  • In admin/structure/block I created a 'menu block' with above menu

With below code I am able to render the menu in page--front.tpl.php

 $block = module_invoke('menu_block', 'block_view', '3');
 print render($block['content']);

But how do I render the Menu block Title?


Your implementation is right but you are missing the print subject, you only print the content of the block.

if you debug the $block variable you will find 'subject' as key with value or without value based on the block if it has a title or not.

So your code should be like this in order to print the title.

 $block = module_invoke('menu_block', 'block_view', '3');
 print render($block['subject']);
 print render($block['content']);
  • The best solution is always the simplest. – Sanjok Gurung May 9 at 10:47

This renders it correctly, including all markup.

    $block = block_load('menu', 'menu-my-profile');
    $block = _block_render_blocks(array($block));
    $block = _block_get_renderable_array($block);
    print render($block);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.