Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created March 27, 2020 10:36
Show Gist options
  • Save cgi-caesar/ce5f706221407fdb9e3150ff804672d9 to your computer and use it in GitHub Desktop.
Save cgi-caesar/ce5f706221407fdb9e3150ff804672d9 to your computer and use it in GitHub Desktop.
aMember (site.php): Active state for custom links within user menu
<?php
Am_Di::getInstance()->hook->add(Am_Event::USER_MENU, function(Am_Event $e) {
$menu = $e->getMenu();
[$config, $items] = Am_Navigation_User::getNavigation();
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
foreach ($config as $item) {
if ($item['id'] == 'custom-link' && ($url == $item['config']['uri'] || $_SERVER['REQUEST_URI'] == $item['config']['uri'])) {
$id = 'custom-link-' . substr(crc32($item['config']['uri']), 0, 8);
$menu->findOneById($id)->setActive(true);
return;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment