Skip to content

Instantly share code, notes, and snippets.

@artygrand
Created July 17, 2016 08:45
Show Gist options
  • Save artygrand/47e3f663fea7ad4392a3d34e5aa70230 to your computer and use it in GitHub Desktop.
Save artygrand/47e3f663fea7ad4392a3d34e5aa70230 to your computer and use it in GitHub Desktop.
SyDES plugin: Add dropdown with all sites in context menu
<?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