Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Last active February 9, 2024 21:42
Show Gist options
  • Save cgi-caesar/ef4e7be3f29d377bb816fa0734de809f to your computer and use it in GitHub Desktop.
Save cgi-caesar/ef4e7be3f29d377bb816fa0734de809f to your computer and use it in GitHub Desktop.
aMember (site.php): Make chosen Link item active in user menu
<?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