Updated
This commit is contained in:
@@ -32,24 +32,34 @@ function vs01_load_pdl(&$b) {
|
||||
return;
|
||||
}
|
||||
|
||||
// On association channel pages: inject civicnav into right_aside.
|
||||
// On association channel pages: read core mod_channel.pdl and inject
|
||||
// civicnav widget as first widget in 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'] ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!$slug) return;
|
||||
|
||||
$raw = @file_get_contents('addon/vs01/config.json');
|
||||
if ($raw === false) return;
|
||||
$cfg = json_decode($raw, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) return;
|
||||
if (!isset($cfg['associations'][$slug])) return;
|
||||
|
||||
// Read core channel PDL. theme_include() checks theme overrides first,
|
||||
// then falls back to view/pdl/. We mirror that lookup here.
|
||||
$p = theme_include('mod_channel.pdl');
|
||||
$layout = $p ? @file_get_contents($p) : '';
|
||||
if (!$layout) {
|
||||
$layout = @file_get_contents('view/pdl/mod_channel.pdl');
|
||||
}
|
||||
if (!$layout) return;
|
||||
|
||||
// Inject civicnav as first widget in right_aside.
|
||||
$b['layout'] = str_replace(
|
||||
'[region=right_aside]',
|
||||
'[region=right_aside]' . "\n" . '[widget=civicnav][/widget]',
|
||||
$layout
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user