Get top level menu-item form active trail

Code: 
<?php $active_trail_items = menu_get_active_trail(); $top_level_title = $active_trail_items[1]['link_title']; // $top_level_path = $active_trail_items[1]['link_path']; // because global redirect is not working for i18n, find the path alias myself $alias = drupal_get_path_alias($_GET['q']); // make sure $remaining_path gets something (albeit NULL), otherwise eval will choke list($top_level_path, $remaining_path) = explode('/', $alias, 2) + Array(NULL, NULL); // including the langcode global $language; $lang_code = $language-?>language;&#13; // because nl is the default, it goes without the langcode&#13; if ($lang_code == 'nl') {&#13; $top_level_full_path = '/'.$top_level_path;&#13; }&#13; else {&#13; $top_level_full_path = '/'.$lang_code.'/'.$top_level_path;&#13; }&#13; &#13; // only print a link when you’re not on the top-level page itself&#13; if ($remaining_path) {&#13; $output = "<a href="$top_level_full_path">$top_level_title</a>";&#13; }&#13; else {&#13; $output = "<span>$top_level_title</span>";&#13; }&#13; return $output;&#13; ?&gt;&#13;

Reactie toevoegen