Updated
This commit is contained in:
@@ -18,15 +18,43 @@ function vs01_module() {}
|
||||
function vs01_load() {
|
||||
register_hook('load_pdl', 'addon/vs01/vs01.php', 'vs01_load_pdl');
|
||||
Widget::register('addon/vs01/Widget/Vs01.php', 'vs01');
|
||||
Widget::register('addon/vs01/Widget/CivicNav.php', 'civicnav');
|
||||
}
|
||||
|
||||
function vs01_unload() {
|
||||
unregister_hook('load_pdl', 'addon/vs01/vs01.php', 'vs01_load_pdl');
|
||||
Widget::unregister('addon/vs01/Widget/Vs01.php', 'vs01');
|
||||
Widget::unregister('addon/vs01/Widget/CivicNav.php', 'civicnav');
|
||||
}
|
||||
|
||||
function vs01_load_pdl(&$b) {
|
||||
if (!is_array($b) || empty($b['module']) || $b['module'] !== 'vs01') {
|
||||
if (!is_array($b) || empty($b['module'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// On association channel pages: inject civicnav into right_aside.
|
||||
if ($b['module'] === 'channel') {
|
||||
$addr = App::$profile['channel_address'] ?? '';
|
||||
$slug = $addr ? explode('@', $addr)[0] : '';
|
||||
if ($slug) {
|
||||
$raw = @file_get_contents('addon/vs01/config.json');
|
||||
if ($raw !== false) {
|
||||
$cfg = json_decode($raw, true);
|
||||
if (json_last_error() === JSON_ERROR_NONE && isset($cfg['associations'][$slug])) {
|
||||
$b['layout'] = str_replace(
|
||||
'[region=right_aside]',
|
||||
'[region=right_aside]' . "
|
||||
" . '[widget=civicnav][/widget]',
|
||||
$b['layout'] ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Load vs01 PDL for vs01 module pages.
|
||||
if ($b['module'] !== 'vs01') {
|
||||
return;
|
||||
}
|
||||
$layout = @file_get_contents('addon/vs01/mod_vs01.pdl');
|
||||
|
||||
Reference in New Issue
Block a user