Hi

I want to render my custom menu called sponsors in page.tpl.php. It has to be inline (class is propably: inline-list)
I tried everything but I couldn't get menu to be rendered in page.tpl.php.(array indexes and other stuff is in wrong format or structure)

I tried searching for menu api and looking into menu functions in theme but nothing worked like supposed to.

What function I need to use to get a correct array of menu/items that can be given to bootstrap theme to render?
It can't be that hard? bootstrap-links.func.php has

function theme_bootstrap_links($variables) {...}

which is supposed to render $variables array (make it into HTML)

Is there a function that can provide array/$variables for this function?
Since none of the menu api's functions didn't work.
Some got almost correct structure and naming in array but only almost.
Am I supposed to manually manipulate some array?

Comments

ETENTION created an issue. See original summary.

markhalliwell’s picture

Component: Code » Documentation
Status: Active » Closed (works as designed)
Issue tags: -menu, -render, -function, -template, -page, -custom menu

Menus in Drupal can be very tricky indeed. I would recommend looking at how we are doing it for the "primary" and "secondary" menus:

http://drupal-bootstrap.org/api/bootstrap/templates%21system%21page.vars...
http://drupal-bootstrap.org/api/bootstrap/templates%21menu%21menu-tree.f...

That site is a work in progress, but feel free to browse all the different functions related menus, links and page.tpl.php. That should help clarify a bit.

ETENTION’s picture

I didn't give up and the most simplest solution was to:
1. add a new theme wrapper function for the menu (yep, I'm not using subtheme)

function bootstrap_menu_tree__menu_sponsors(&$variables) {
  return '<ul class="menu nav navbar-nav secondary">' . $variables['tree'] . '</ul>';
}

2. add this in page.tpl.php
print drupal_render(menu_tree_output(menu_tree_all_data('menu-sponsors')));

Though, all in all the whole "problem" was only to get a navbar-nav class added to that menu.

And yet, this is quite hardcoded solution... but it works so it is enough for now.

muthuraja143’s picture

page.tpl.php

$main_menu = menu_navigation_links('main-menu');
 print theme('links__menu_your_custom_menu_name', array('links' => $main_menu));

template.php

function your_theme_name_preprocess_page(&$vars) {

$main_menu = menu_navigation_links('main-menu');

$vars['custom_menu'] = theme('links__menu_your_custom_menu_name', array('links' => $main_menu));

}

it's work for me.

auxiliaryjoel’s picture

@muthuraja143 can you tell me in Drupal 7, if I want to render my main navigation menu, how I could that?
I want to separate the parts of the menu and call them individually so I can wrap classes around the burger menu.