Created
September 25, 2012 10:26
-
-
Save GoZOo/3781074 to your computer and use it in GitHub Desktop.
redéfinir le fil d'ariane pour prendre en compte le bon element de menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Définition du Breadcrumb en fonction d'un Node | |
*/ | |
function _breadcrumb_for_a_node($link_path = NULL){ | |
$breadcrumb = array(); | |
if(!is_null($link_path)){ | |
$breadcrumb[] = l(t('Home'), '<front>'); | |
$item = menu_tree_set_path('main-menu', $link_path); | |
$tree = menu_tree_page_data('main-menu', NULL, TRUE); | |
list($key, $curr) = each($tree); | |
while ($curr) { | |
$link = $curr['link']; | |
if ($link['in_active_trail']) { | |
// Add the link to the trail, unless it links to its parent. | |
if (!($link['type'] & MENU_LINKS_TO_PARENT)) { | |
// The menu tree for the active trail may contain additional links | |
// that have not been translated yet, since they contain dynamic | |
// argument placeholders (%). Such links are not contained in regular | |
// menu trees, and have only been loaded for the additional | |
// translation that happens here, so as to be able to display them in | |
// the breadcumb for the current page. | |
// @see _menu_tree_check_access() | |
// @see _menu_link_translate() | |
if (strpos($link['href'], '%') !== FALSE) { | |
_menu_link_translate($link, TRUE); | |
} | |
if ($link['access']) { | |
$breadcrumb[] = l($link['title'], $link['href'], $link['localized_options']); | |
} | |
} | |
$tree = $curr['below'] ? $curr['below'] : array(); | |
} | |
list($key, $curr) = each($tree); | |
} | |
drupal_set_breadcrumb($breadcrumb); | |
} | |
return $breadcrumb; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment