Created
July 17, 2016 08:45
-
-
Save artygrand/47e3f663fea7ad4392a3d34e5aa70230 to your computer and use it in GitHub Desktop.
SyDES plugin: Add dropdown with all sites in context menu
This file contains 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 | |
$app->on('before.module', '*', function() use($app){ | |
$app->response->context['sites'] = array( | |
'title' => 'Сайты', | |
'link' => '', | |
'children' => array(), | |
); | |
$allsites = $app->cache->get('allsites'); | |
if (!$allsites){ | |
foreach (glob(DIR_SITE . 's*', GLOB_ONLYDIR) as $sitepath){ | |
$conf = include $sitepath . '/config.php'; | |
$site = str_replace(DIR_SITE, '', $sitepath); | |
$allsites[$site] = $conf['name']; | |
} | |
$app->cache->set('allsites', $allsites, 604800); | |
} | |
foreach ($allsites as $site => $name){ | |
$app->response->context['sites']['children'][] = array( | |
'title' => $name, | |
'link' => '/admin/?site='.$site, | |
'modal' => false | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment