hi there,
this is not really a classical how-do-i question, anyway, here we go:
i am building a multilingual site with the i18n.module and i am having big troubles highlighting the current page in a custom menu block.
my script below does:
1. point the menu entry links to the translation of a node/term given in the menu when another language than english is selected.
2. display a translation of the menu item name via the t() funtion (translation imported via .po file).
3. highlight the current node/taxonomy in the menu (only works for english - that's my problem)
i am overriding the theme_menu_item_link() function in my theme's template.php with this:
/**
* Override theme_menu_item_link() from includes/menu.inc
* to translate menu item titles and descriptions
* and to get the right url for the current language
*/
function phptemplate_menu_item_link($item, $link_item) {
// get the currently selected language:
$lang = i18n_get_lang();
// initialise link attributes array:
$attributes = array();
// if a menu item desciption is given, add it as link title:
if (array_key_exists('description', $item)) {
$attributes['title'] = t($item['description']);
}
// get the current drupal path without the language code:
$path = i18n_get_normal_path(_i18n_get_original_path());
// highlight the active menu item:
if ($link_item['path'] == $path) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
}
else {
$attributes['class'] = 'active';
}
}
// build a link that points to the translated version of a node/term
// (if a translation exists):
$link = i18n_l(t($item['title']), $lang , $link_item['path'], $attributes);
return $link;
}
task 1. and 2. work fine, but as the translated version of a page has a different node id, the menu block does not recognise it anymore as the currently selected one. the consequence is that the current page is not highlighted in the menu and that children are not displayed when a internationalised page is shown.
any hints or pointers?
thanks a lot, meinhard.