diff --git a/hubzilla/addon/vs01/civicnav.json.template b/hubzilla/addon/vs01/civicnav.json.template new file mode 100644 index 0000000..b45fb36 --- /dev/null +++ b/hubzilla/addon/vs01/civicnav.json.template @@ -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 + } + ] +} diff --git a/hubzilla/addon/vs01/mod_vs01.pdl b/hubzilla/addon/vs01/mod_vs01.pdl index 2bb989c..e84ef04 100644 --- a/hubzilla/addon/vs01/mod_vs01.pdl +++ b/hubzilla/addon/vs01/mod_vs01.pdl @@ -9,6 +9,7 @@ $content [/region] [region=right_aside] +[widget=civicnav][/widget] [widget=notifications][/widget] [widget=newmember][/widget] [/region] diff --git a/hubzilla/addon/vs01/vs01.php b/hubzilla/addon/vs01/vs01.php index b0b8fb3..91c7fca 100644 --- a/hubzilla/addon/vs01/vs01.php +++ b/hubzilla/addon/vs01/vs01.php @@ -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');