Created
March 27, 2020 10:36
-
-
Save cgi-caesar/ce5f706221407fdb9e3150ff804672d9 to your computer and use it in GitHub Desktop.
aMember (site.php): Active state for custom links within user menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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