| Project: | Menu Trails |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
I have installed Menutrail on a multilingual site running on three domains, one for each language. Each language has another primary links menu. The settings are saved separately using this in my settings.php: (after this tip here http://drupal.org/node/165527#comment-870834).
$conf['i18n_variables'] = array(
'menutrails_menu',
'menutrails_node_types',
'menutrails_terms',
);Now everything works great, it even works for the Biblio node-type (from Biblio module. BUT, for some reason it only works on one of the menus, the English one. On the other two domains, using different primary menus, only for the Biblio type the correct parent menu will not be set. I've spent hours reading about and trying all kinds of tricks, no luck. But since it works for one language/menu with Menutrails, any suggestions to make it work?
Comments
#1
I'm willing to bet there is additional code needed to support internationalization. This will need some further research to figure out. Thanks for bringing this to my attention!
#2
Cool, I'll be available for testing when there are new developments.
#3
Excellent. I saw all the code in the other thread here:
http://drupal.org/node/165527
It'll probably be some days before I really have time to dig into it, but i18n is an important feature (esp for Drupal 6) and I want to support it.
#4
I added 'menutrails_menu', 'menutrails_node_types' and 'menutrails_terms' to 'i18n_variables' in my settings.php as it has been said here and tested it. For the moment everything seems to work fine. I have created a menu for my Spanish content (called Test-es) and another one for its translation to Basque (called Test-eu). After configuring menu trails module in both languages I got the active-trail class in the defined parent items as I expected (using both nodetypes and taxonomy configuration), so I think that this solves the issue.
I'm using Internationalization 6.x-1.0 and Menu Trails 6.x-1.0. Can anyone give more feedback?
#5
I have tried, unsuccessfully, to use Menu Trails on a new bilingual (French/English) D6 site. I added the menutrails_* variables to the i18n_variables list in settings.php (as I have done for numerous other modules, so I know this 'works'), and this did indeed allow me to configure separate English & French assignments in the UI.
On this site, two site-specific menus are used (i.e. not Primary or Secondary links) - one for English and one for French.
Associating by node type or taxonomy works great for the primary language (English), and results in appropriate breadcrumbs and "active" item indication.
It does not appear to be doing anything at all when operating in French, however.
Is there anywhere or anything else I could check?
#6
Set the multilingual variables. If you have urls going to the same path in both languages like a view that has a language filter for example, you need to hack the module a little.
To the owner of this module: proper i18n support would be nicer, but for now this fix works fine for me.
Change this function :
function _menutrails_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {foreach ($tree as $data) {
if ($data['link']['depth'] > $depth_limit) {
// Don't iterate through any links on this level.
break;
}
if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
$title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
if (!$data['link']['hidden']) {
$options[$data['link']['href']] = $title;
}
if ($data['below']) {
_menutrails_parents_recurse($data['below'], $menu_name, $indent .'--', $options, $exclude, $depth_limit);
}
}
}
}
Into:
function _menutrails_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {foreach ($tree as $data) {
if ($data['link']['depth'] > $depth_limit) {
// Don't iterate through any links on this level.
break;
}
if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
$title = $indent .' '. truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
if (!$data['link']['hidden']) {
if (module_exists('i18n')) {
if (i18n_get_lang() == $data['link']['localized_options']['langcode']) {
$options[$data['link']['href']] = $title;
}
}
else {
$options[$data['link']['href']] = $title;
}
}
if ($data['below']) {
_menutrails_parents_recurse($data['below'], $menu_name, $indent .'--', $options, $exclude, $depth_limit);
}
}
}
}
#7
I can confirm that entering the above mentioned lines of code into settings.php works perfectly. This, however, seems like a workaround. Should this somehow be entered into the module itself?
#8
I have the same problem, but adding the 'i18n_variables' did the trick for me.
It works great! Thanks
#9
subscribe
#10
Confirming that this at the end of the settings.php
$conf['i18n_variables'] = array(
'menutrails_menu',
'menutrails_node_types',
'menutrails_terms',
);
and applying the patch I attached with the above code from #6 works great.
#11
maybe you should use http://drupal.org/project/node_breadcrumb instead
#12
This patch is a simpler approach IMO, it uses the
i18nmenu_localize_tree()function to transparently switch to a localized menu tree which allows the rest of menutrails to keep on running without knowing the difference.#13
Subscribing
#14
Patch #12 worked perfectly - for a single multi-lingual menu. Many thanks, James.
#15
The attached patch is the same as #12 except that it allows menutrails to play nice with the i18nmenu_node module by calling menu_tree_all_data instead of menu_tree_page_data.
#16
Neither #12 nor #15 "plays nicely" with i18nmenu_node. #12 doesn't show breadcrumbs. #15 doesn't show links in the menu.
#17
Regarding #16, breadcrumbs and menu links display properly for me. You may want to check your config settings, and possibly check for conflict with another module. Also, if you're using DHTML menu, you'll need to set all parent links to be expanded, see http://drupal.org/node/299783#comment-3781566.
#18
Hello Robert,
I wonder how you manage to get breadcrumbs displayed, given menu_tree_all_data has even different signature from menu_tree_page_data and requires second parameter to set 'in_active_trail' property. AFAICS, there is no way to get breadcrumbs with menu_tree_all_data(). Instead, using patch from #12 and setting content negotiation to "all languages" solves the problem, but that's not the perfect way.
To display everything correctly, I did the following:
1. Added
<?phpif (module_exists('i18nmenu_node')) {
i18nmenu_node_navigation_links_prepare();
}
?>
2. I changed
theme_get_setting('zen_breadcrumb');totheme_get_setting('zen_breadcrumb', TRUE);in zen_breadcrumb (in fact, I overrode zen_breadcrumb in my sub-theme).This seems like an ugly solution to me, but the only one that works. Hopefully someone can come up with something better.
#19
Doh, I'm using the custom_breadcrumb module for breadcrumbs, not menutrail, which is probably why breadcrumbs are working. Have you tried calling i18nmenu_node_navigation_links_prepare() from hook_nodeapi('view')? Maybe that would do the trick?
#20
any news on this topic?? -.-
#21
Subscribing
#22
Subscribing
#23
I have added in menutrails_get_breadcrumbs function, after $tree = menu_tree_page_data($menu); the following code:
//i18n menu integrationif(module_exists('i18nmenu')){
i18nmenu_localize_tree($tree);
}
I think this function is that translates the tree as the language of each item. What do you think is the best solution?
#24
What about this? It is the only working in my case
@@ -104,9 +103,9 @@ function _menutrails_recurse_crumbs($tree, $item, &$crumbs, $above = array()) {
}
if ($menu_item['link']['link_path'] == $item['href']) {
foreach ($above as $trail_item) {
- $crumbs[] = l($trail_item['link']['link_title'], $trail_item['link']['link_path']);
+ $crumbs[] = l(t($trail_item['link']['link_title']), $trail_item['link']['link_path']);
}
- $crumbs[] = l($menu_item['link']['link_title'], $menu_item['link']['link_path']);
+ $crumbs[] = l(t($menu_item['link']['link_title']), $menu_item['link']['link_path']);
break;
}
#25
Subscribing