This commit is contained in:
2026-06-07 07:47:34 -04:00
parent d1a244aae6
commit 6d37816e11
3 changed files with 56 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
{
"_note": "Copy to civicnav.json. Do not commit civicnav.json. Each addon registers one entry. Order determines display order in the nav widget.",
"addons": [
{
"id": "vs01",
"label": "Vital Signs",
"module": "vs01",
"icon": "heart-pulse",
"enabled": true
},
{
"id": "dsc01",
"label": "DSC Categories",
"module": "dsc01",
"icon": "folder-open",
"enabled": true
},
{
"id": "scn01",
"label": "Scenarios",
"module": "scn01",
"icon": "file-text",
"enabled": true
}
]
}

View File

@@ -9,6 +9,7 @@ $content
[/region]
[region=right_aside]
[widget=civicnav][/widget]
[widget=notifications][/widget]
[widget=newmember][/widget]
[/region]

View File

@@ -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');