Hi,

I would like to find some way of placing a menu block in a node. I have searched the forums and documentation but can't find anything that gives me a clue.

I have a set of primary menu items set horizontally across the top of a page....Home, About , Contact...that kind of thing. I also want to have a 'Search' item that linkes to a node. The node would contain a list of links that pass arguments to Views, (the site is a classifieds ads site). The functionality I would like is similar to what you get when you select the Drupal 'administer' menu item. A page with a list of links and guidance.

Now I know I can enter each link manually into a new 'page' using html easily enough but I already have a menu set up with all the links I want (there are quite a few) and I would like to display only that menu in a node. I have tried allocating the menu block to a region immediately above the content but it's not quite right. There has to be a node displayed for it to show (albeit a blank one) and it just doesn't cut it.

Maybe I'm missing an easy solution in a 'can't see the wood for the trees' sort of way if anyone has any suggestions.

Many thanks

Comments

jastraat’s picture

Example with a region called 'node_top'

In the theme .info file where you list regions, add:
regions[node_top] = Node top

In template.php add:

/**
* Override or insert variables into the node templates.
*
* @param $vars
*   An array of variables to pass to the theme template.
* @param $hook
*   The name of the template being rendered ("node" in this case.)
*/
function YOURTHEMENAME_preprocess_node(&$vars, $hook) {
  $vars['node_top'] = theme('blocks', 'node_top'); 
}

In node.tpl.php add:

<?php if ($node_top && !$teaser): ?>
  <div id="node-top">
    <?php print $node_top; ?>
  </div>
<?php endif; ?>

Then, on the block administration page, put the menu block into the 'Node top' region - or whatever you called it.

------------------------------
http://fraggles.artsci.wustl.edu (Drupal user documentation and development blog)

drunkencelt’s picture

Thank you both for your tips.

Jmburnz - I found some articles by searching on Google as you suggested. Made a difference using different terms. Not always sure what terms to search for so thanks.

Jastraat - I used your code, changed it a little to match my theme and it worked straight off. I've done a bit of theming previously so I understand how it works. I just couldn't see, or know enough about php, to put it all together without a little help.

The result is precisely what I wanted.

Many thanks for taking the time to help. Much appreciated.