One item in the menu has sub-items that point to the same page (just with different arguments) ex:
Products - List item 1 \products?pid=1 - List item 2 \products?pid=2 - List item 3 \products?pid=3
Drupal assigns the "active" class in the
I'm overwriting the menu_link function in template.php to remove the active class but the class remains in the tag
function mytheme_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
if (strtolower($element['#title']) == 'Products') {
if (isset($_GET['pid'])) {
$currID = $_GET['pid'];
foreach ($element['#below'] as $Taxonomy) {
if ($currTaxonomyID != $Taxonomy['#localized_options']['query']['pid']) {
$mlid = $Taxonomy['#original_link']['mlid'];
$key = array_search('active', $Taxonomy['#attributes']['class'], TRUE);
if ($key) {
unset($element['#below'][$mlid]['#attributes']['class'][$key]);
$element['#below'][$mlid]['#localized_options']['attributes']['class'][$key] = '';
}
// remove active-trail class
$key = array_search('active-trail', $Taxonomy['#attributes']['class'], TRUE);
if ($key) {
$element['#below'][$mlid]['#attributes']['class'][$key] = '';
}
}
}
}
}
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Final Result:
<ul class="menu nav">
<li class="first leaf menu-mlid-44253">
<a href="/products?pid=1" title="Best Practices" class="active">Best Practices</a>
</li>
<li class="leaf menu-mlid-44254">
<a href="/products?pid=2" title="Checklists" class=" active">Checklists</a>
</li>
....
How can I remove the class "active" from the tag?
My menu Structure:
-Clients
-Products
-prod1 (url:\\products?pid=1)
-prod2 (url:\\products?pid=2)
-prod3 (url:\\products?pid=3)
-prod4 (url:\\products?pid=4)
-About
if (strtolower($element['#title']) == 'Products') {
Fix it and it may work.