Skip to content

Instantly share code, notes, and snippets.

View cgi-caesar's full-sized avatar

Andrey Yerokhin cgi-caesar

View GitHub Profile
@cgi-caesar
cgi-caesar / dashboard.php
Created October 13, 2021 15:00
Dashboard Plugin (replace standard controller with custom one)
<?php
class Am_Plugin_Dashboard extends Am_Plugin
{
const PLUGIN_STATUS = self::STATUS_PRODUCTION;
const PLUGIN_COMM = self::COMM_COMMERCIAL;
const PLUGIN_REVISION = '@@VERSION@@';
protected $_configPrefix = 'misc.';
@cgi-caesar
cgi-caesar / site.php
Last active March 24, 2022 14:29
aMember (site.php): Sort Items in Active Resources Widget Alphabetically
<?php
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function (Am_Event $e) {
if (stripos($e->getTemplateName(), 'blocks/member-main-resources.phtml') !== false) {
usort($e->getView()->resources, function ($a, $b) {return strtolower($a->title) <=> strtolower($b->title);});
}
});
@cgi-caesar
cgi-caesar / site.php
Last active February 9, 2024 21:42
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);
}
});