When defining the menu item, I can only choose a unique URL for language. But I want that a bunch of pages, one of them the referenced by the menu item, highlight that menu item (Products) so I know I am in that section of the page. For example:
www.example.com/products
www.example.com/search-product
www.example.com/product-detail
all would have to highlight the menu-item := products, that which references the first URL above.
I have tried with the following code but I am not sure if there is a faster and more direct approach, it seems too convoluted to me to theme() nothing to keep the above desired effect
Code:
print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
),
));
function theme_links__system_main_menu($variables) {
$html = "<ul>";
foreach ($variables['links'] as $link) {
// HERE I would change $link['href'] to merge the 3 links
//together and make that this item is hilited when I am in one of the 3
//links. Of course, the href link will direct to the first one, but
//the hilite will make the user to know that she is in this section.
$html .= "<li>".l($link['title'], $link['href'], $link)."</li>";
}
$html .= " </ul>";
$html .= "";
return $html;
}
Another coded approach:
$a = menu_tree_output( menu_tree_page_data("main-menu") );
print "<ul>";
foreach($a as $key => $value){
active = "";
if($value["#href"] == current_path() || ( drupal_is_front_page() && $value["#href"] == "<front>" ) ){
// HERE I would change $link['href'] to merge the 3 links
//together and make that this item is hilited when I am in one of the 3
//links. Of course, the href link will direct to the first one, but
//the hilite will make the user to know that she is in this section.
$active = 'class="active"';
}
if($value["#href"] == "<front>"){
$url = "";
}else{
$url = drupal_get_path_alias($value["#href"]);
} // if
if($value["#title"] != "") print '<li><a ' . $active . ' href="' . $base_url . "/" . $language->language . "/" . $url . '">' . $value["#title"] . "</a></li>";
} // foreach
print "</ul>";