Last active
February 9, 2024 21:42
-
-
Save cgi-caesar/ef4e7be3f29d377bb816fa0734de809f to your computer and use it in GitHub Desktop.
aMember (site.php): Make chosen Link item active in 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(); | |
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); | |
if ($_ = $e->getDi()->linkTable->findFirstByUrl($url)) { | |
$menu->findOneById("link-{$_->pk()}")->setActive(true); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment