4

I have a menu called main-menu. I want to post it twice as a block: one block with a main-menu in the header, and one block with a main-menu in the footer. But Drupal 7 will not allow it. Drupal 7 only allows me to post the block once...either in the header or in the footer.

Is there another way? If not, I will use Javascript to clone the entire main-menu html node and append to footer node.

  • This thread might help: drupal.stackexchange.com/questions/9677/… – nmc Sep 7 '11 at 20:37
  • Why don't you simply build two menus (with the same links) and post each one to a different region? – user16316 Apr 4 '13 at 19:02
8

The Menu Block module will do this.

So… have you ever used the Main and Secondary menu links feature on your theme and wondered “how the hell do I display any menu items deeper than that?”

Well, that’s what this module does. It provides configurable blocks of menu trees starting with any level of any menu. And more!

| improve this answer | |
3

It seems that the MultiBlock module can do this.

The MultiBlock module solves this problem by allowing you to create multiple block instances of already existing blocks.

| improve this answer | |
  • I could not get MultiBlock to work with Drupal 7. I did have success with Menu Block. – webworm Nov 23 '12 at 22:47
  • It worked for me, you will just need to create an instance from block page. – Fahad Ur Rehman Mar 15 '13 at 7:12
1

You can do this with the Render API in Drupal 7 quite easily, specifically look at hook_page_alter(). The Render API is a lot like the Forms API, you create content as arrays that describe the content, rather than creating raw HTML. Blocks are now created using these render arrays, which makes them very easy to manipulate from the module or theme layer. You can check out the documentation on the Render API for more details. Also, I found some Drupalcon videos quite helpful: http://www.archive.org/details/drupalconchi_day3_the_render_api_in_drupal_7 and http://www.archive.org/details/PageRenderDrillDownInDrupal7 are good ones.

In your specific case, you'd implement hook_page_alter() something like this assuming the block is called 'main-menu' and it's in the 'header' region of your page...

function mymodule_page_alter(&$page) {
  // get the block you're after from the $page array
  $menu_block = $page['header']['main-menu'];

  // copy the block to another location in the page array
  $page['footer']['main-menu'] = $menu_block;
}

This code grabs the definition of the 'main-menu' block and copies it to the footer region. This will cause Drupal to print the block twice. This specific example is also shown in at least one of the videos linked to above.

| improve this answer | |
1

also you can print the menu block a second time through the template page.tpl.php file or the one what you want to modify... doing something like this...

<body>
      <div class="header">
            <?php print render($page['menu']); ?>
      </div>
      <div class="content">
            .....
            .....page content and content blocks
            .....
      </div>
      <div class="footer">
            <?php print render($page['menu']); ?>
      </div>
</body>

That should make it, and with css you can make the style Change if needed

.header > .menu{..styles menu header...}
.footer > .menu{..styles menu footer...}
| improve this answer | |
0

Menu clone allows you to clone a menu, but adjust it as you like, before creating a block that you can add anywhere in your site. It's a bit more flexible than menu block.

| improve this answer | |

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.