Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

The Menu module contains 2 sources to assign menus to my site.

How do I add a 3rd source?

Reading through the Zen theme code, I see the variables $main_menu, and $secondary_menu.

I would like to access this 3rd menu source through a variable called $global_menu.

How do I set this variable from a module?

EDIT

I put this at the bottom of the zen_proprocess_page hook in template.php

$global_menu = menu_navigation_links('menu-global-menu');

and was able to access it with this in page.tpl.php so thank you for that advice

<?php if ($global_menu): ?>
   <div class="global-navigation">
      <ul class="nav">
      <?php foreach ($global_menu as $key => $value): ?>
        <li>
          <a href="<?php print($value["href"]); ?>" class="global-link" ><?php print($value["title"]); ?></a>              
        </li>
      <?php endforeach;  ?>
    </ul>
    </div>
 <?php endif; ?>

EDIT

Moved multipart question to new question

share|improve this question
1  
To be clear, you want to add a third menu to your Zen theme. Is that correct? –  Brandon Bearden Jun 18 '12 at 4:24
    
What I have is a main site with several sub sites. I want to add a global navigation bar that is managed in the main site to all subsites. So I don't want to interfere with the way the web master have designed the navigation on the sub sites. I figured a third global menu would be the way. I'm very new to Drupal and the way it operates doesn't completely make sense to me yet, so I'm willing to concede my approach may be rubbish. –  Peter Jun 18 '12 at 22:22
    
I really want a 3rd menu for all of my drupal independent of theme. I was hoping there was a module that extended the menu module adding a new form to the menu sources page I mentioned in the question. and that once I turned that on I could theme it appropriately or better still it provided it's own rendering function so all the site admin would have to do is tick a box and have the corporate global menu for the his/her subsite. –  Peter Jun 18 '12 at 22:40
1  
The second part of your question should really be a new question. You should also accept the most relevant answer for the first part. –  Chapabu Jun 18 '12 at 23:14

2 Answers 2

up vote 1 down vote accepted

To be able to put it in a theme variable I think you're looking at something like the following. Please note I haven't tested this, but i should put you in the right direction.

In your template.php or a module:

function MYTHEME_preprocess_page($vars){
  $global_menu = menu_navigation_links('menu-global-menu');
  $vars['global_menu'] = theme('links__menu_global_menu', array('links' => $global_menu));
}

Then clear your theme registry/caches.

share|improve this answer

From what I understand you want a create a menu (called 'global menu') separate from the 'Main' and 'Secondary' menus,and you want to display that at a desired location in your theme.

The best way to do this is -

  1. Create a new Menu from - YOURSITE/admin/structure/menu/add. Call it 'global menu'
  2. Add links to it
  3. Goto the blocks page and place the 'global menu' block (which is automatically generated for you after step #1) in the theme region of your choice - YOURSITE/admin/structure/block
share|improve this answer
    
OP is asking how to put their menu into a template variable - this doesn't actually answer that question. –  Chapabu Jun 18 '12 at 8:43
1  
I assumed Peter wanted to add/theme another menu (beyond the default 2) and looking at theme thought that the only way to do so is using a theme variable. So I suggested the alternate way. Yeah, I agree that is a lot of assumption on my end :-p Peter: The below answer by @Chapabu is what you should look for getting a menu inside a theme_variable, if that is what you are looking for. –  Sumeet Pareek Jun 18 '12 at 8:56
    
You both are right, I made the mistake of asking a 2 part question. –  Peter Jun 18 '12 at 22:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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