2

I need to place a menu block (the main-menu) inside a views template file - the template for the rows design.

I tried

$block = module_invoke('system','main_menu'); print render($block['content']);

and

$block = module_invoke('menu','main_menu'); print render($block['content']);

but nothing works.

Can anyone please give me a little help?

0

I used the code which was rendering the main-menu from page.tpl.php file in the theme that I am using in my current project Nexus.

<div id="main-menu">
<?php
 if (module_exists('i18n_menu')) {
   $main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
 }
 else {
   $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
}
 print drupal_render($main_menu_tree);
 ?>
</div>

So i used the following extraction:

<?php
$main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
print drupal_render($main_menu_tree);
?>

in a views template file for row design. The main menu appeared with content.

Note: The menu which will be rendered might not be themed.

0

I solved it by placing the region with the block into the view template:

<?php print render(block_get_blocks_by_region('mainmenu')); ?>

That works.

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.