I am making an attempt to print a drupal menu exterior drupal. As a way to obtain this I ran the bootstrap as follows:
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
And I render my menu as follows:
public static perform getDrupalMenu($menuName) {
$menu_output = &drupal_static(__FUNCTION__, array());
if (!isset($menu_output[$menuName])) {
$tree = menu_tree_all_data($menuName);
$menu_output[$menuName] = menu_tree_output($tree);
}
return render($menu_output[$menuName]);
}
Which is mainly only a copy of the menu_tree
perform AND with menu_tree_all_data as a substitute of menu_tree_page_data so I get all hyperlinks it doesn’t matter what web page I am on.
The whole lot works fantastic thus far, my menu is printed, all people is completely happy… however sadly my hyperlinks are incorrect one way or the other. To unravel this I’ve used an answer for absolute hyperlinks as described right here:
The way to pressure absolute hyperlinks on a menu tree in Drupal 7
So I take advantage of:
perform mythemename_menu_link(array $variables) {
$aspect = $variables['element'];
$sub_menu = '';
if ($aspect['#below']) {
$sub_menu = drupal_render($aspect['#below']);
}
$output = l($aspect['#title'], $aspect['#href'], array_merge($aspect['#localized_options'], array('absolute' => TRUE)));
return '<li' . drupal_attributes($aspect['#attributes']) . '>' . $output . $sub_menu . "</li>n";
}
This works fantastic on my drupal website, however the place I name the getDrupalMenu() after initializing the bootstrap it doesn’t work (empty consequence, not even the unique one). I in all probability need to set the theme or one thing, however I am unable to discover what or the place to take action.
Simply to be clear: after I change the code in core (menu.inc) is works fantastic on each websites… it simply provides en empty consequence after I override it within the theme.
Any pointers or options ?