Menu links not .active when using localizer
teebo - March 13, 2008 - 14:37
| Project: | Localizer |
| Version: | 5.x-2.1 |
| Component: | Code |
| Category: | support request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
I'm using localizer 5.x-3.3 and Pathauto.
Everything works perfectly except for the Primary and Secondary menu.
None of them have the .active class when I'm in the node. Wether it be the orignial node or the translated node.
If I manually add the language abbreviation in url_alias.src in the database, it works.
Has anyone else had this issue before?
Am I doing something wrong?

#1
Sorry, I'm not sure what could be causing this. One bug that sounds similar is the image gallery alias menu problem: http://drupal.org/node/225002
Perhaps it's a broader problem than that description claims?
#2
Thanks for the reply.
Here is the link to the website: link
#3
I found a solution.
Thanks to this note: http://drupal.org/node/41629#comment-364435
It's a dirty solution because you have to modify common.inc; but it does the job (until a real fix can be found).
Line #1275 in common.inc; replace:
if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page())) {By
if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page()) || (drupal_get_normal_path(i18n_get_lang(). "/". $path) == $_GET['q'])) {#4
You marked this as critical, but I'm afraid I don't see this as a critical item since it only is visible with the localizer module. That's not critical in the scope of Pathauto.
If you marked it as critical because you feel this should be worked on faster then I suggest:
1. State clearly what Pathauto needs to do differently to the extent you can. You've described a symptom, but it's not clear specifically what Pathauto is doing wrong and what it should be doing.
2. Provide a bounty to get people interested in working on it. I'm not personally interested in working on it and unless you can fix it it seems unlikely to get attention.
#5
Sorry about that.
It's probably a Localizer issue seeing the (partly)fix I found.
#6
Yes, I agree this is a dirty solution but it’s better than no solution. Here is the code for using with localizer module. I hope this will help.
But I would still like to request the Module maintainers of Localizer module to come up with some proper solution within the module to avoid such hacks.
Line #1275 in common.inc; replace:
if (($path == $_GET['q']) || ($path == '' && drupal_is_front_page())) {
By
if (($path == $_GET['q']) || ($path == '' && drupal_is_front_page()) || (drupal_get_normal_path(localizer_get_language() . "/". $path) == $_GET['q'])) {
#7
A slightly less dirty approach would be to override HTML rendering of menu links with a theme function... followed by a fixed version of the l() function.
Placing the following 2 functions in template.php will do the trick without having to mess with common.inc
function phptemplate_menu_item_link($item, $link_item) {return fixed_l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}
function fixed_l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = FALSE) {//if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page())) {
if (($path == $_GET['q']) || ($path == '<front>' && drupal_is_front_page()) || (drupal_get_normal_path(i18n_get_lang(). "/". $path) == $_GET['q'])) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
}
else {
$attributes['class'] = 'active';
}
}
return '<a href="'. check_url(url($path, $query, $fragment, $absolute)) .'"'. drupal_attributes($attributes) .'>'. ($html ? $text : check_plain($text)) .'</a>';
}
---
Arhips the Super CEO
www.comeks.com