Skip to content

Instantly share code, notes, and snippets.

@timrobertson100
Created September 9, 2014 14:27
Show Gist options
  • Save timrobertson100/6d20e93fe889eb6b5754 to your computer and use it in GitHub Desktop.
Save timrobertson100/6d20e93fe889eb6b5754 to your computer and use it in GitHub Desktop.
// Detect the URLs with the ISO code, and ensure the tab is highlighted
if (isset($variables['page']['menu']['menu_block_gbif_navigation_analytics'])) {
$current_path = explode('/', current_path());
// e.g. analytics/country/<ISO>/about or analytics/country/<ISO>/published
if (count($current_path) == 4) {
// items where registered in menu without the ISO
$menu_item = $current_path[0] . '/' . $current_path[1] . '/' . $current_path[3];
// find the registered menu item and add the "active" CSS class to the attributes
foreach ($variables['page']['menu']['menu_block_gbif_navigation_analytics']['#content'] as $k => $tab) {
if (gettype($k) == 'integer') {
if ($tab['#href'] == $menu_item) {
watchdog('analytics', 'setting it!', array(), WATCHDOG_DEBUG);
// make it active
array_push($variables['page']['menu']['menu_block_gbif_navigation_analytics']['#content'][$k]['#attributes']['class'], "active");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment