diff --git a/README.md b/README.md index 72a0847..eba1737 100644 --- a/README.md +++ b/README.md @@ -381,9 +381,18 @@ the variant's `preview.png` is identical to the mother's. never hardcode house-style values in shared files (`views/`, `css/`, `scripts/`), because those are inherited by all variants. 2. In the private variants repo, create `variants/.json` with the - variant name/title/description and only the house-style option keys with the - client values, plus a `/` asset folder (logos, `files/fonts/`, - `css/variant.css`, `files/preview.svg`/`preview.png`). + variant name/title/description and the option values, plus a `/` + asset folder (logos, `files/fonts/`, `css/variant.css`, + `files/preview.svg`/`preview.png`). The json may list **ALL option keys** + of the mother `config.xml` (109 at the time of writing) so it is visible what + CAN be set per variant: an **empty value (`""`) means "inherit the default + from vanilla_respondage"** — `build.php` skips empty values, so only the + filled-in keys are written into the variant config. Fill in the house-style + values you know (keys marked `HOUSE-STYLE` in `config.xml`: colors, fonts, + font sizes/colors/weights, logo files/margins, background image/color); + leave the rest empty. Legacy keys (e.g. `logotopmargin`, `logo`, + hex values in chooser options) are still accepted and migrated by + `build.php`, but writing the new-model keys directly is recommended. Naming convention: folder/json `respondage_`, metadata `name` `respondage_` (must equal the file name), `title` `" LimeSurvey theme"` (e.g. `respondage_acme` → diff --git a/variants/build.php b/variants/build.php index 99aac73..89f7c0e 100644 --- a/variants/build.php +++ b/variants/build.php @@ -56,6 +56,11 @@ * "fontOptions": [{"value": "my_custom_font", "label": "My Custom Font"}] custom fonts, * appended to the "Custom (this theme)" optgroup of the font dropdown * + * The json may list ALL option keys of the mother config.xml (row 245): an EMPTY + * value ("" or null) means "inherit the mother theme's default" and is skipped — + * only non-empty values are written into the variant config. So a variant json + * can show every key the user CAN set, while leaving unknown ones to inherit. + * * Output: * ..//config.xml (next to this theme, in upload/themes/survey) * @@ -244,7 +249,7 @@ if (!empty($definition['options']) && !is_array($definition['options'])) { // the DEFAULT value of the "font" option (so it is pre-selected in the options page // dropdown), unless the json sets options.font explicitly. if (!empty($definition['fontOptions']) - && (empty($definition['options']) || !isset($definition['options']['font']))) { + && (empty($definition['options']) || !isset($definition['options']['font']) || $definition['options']['font'] === '')) { $definition['options']['font'] = preg_replace('/[^a-z0-9_]/i', '_', (string) $definition['fontOptions'][0]['value']); } // --- Prompt M migration: map the OLD logo json keys to the NEW per-logo keys --- @@ -258,7 +263,7 @@ $logoPositions = ['brand', 'center', 'right']; if (!isset($definition['options']) || !is_array($definition['options'])) { $definition['options'] = []; } -if (isset($definition['options']['logotopmargin'])) { +if (isset($definition['options']['logotopmargin']) && $definition['options']['logotopmargin'] !== '') { $margin = preg_replace('/[^0-9]/', '', (string) $definition['options']['logotopmargin']); if ($margin === '') { $margin = '15'; @@ -337,6 +342,9 @@ if ($optionsNode === null) { exit(1); } foreach (($definition['options'] ?? []) as $key => $value) { + if ($value === '' || $value === null) { + continue; // row 245: empty value = inherit the mother theme's default + } $matches = $xpath->query('//options/' . $key); if ($matches->length === 0) { fwrite(STDERR, "Option '$key' from $definitionFile does not exist in the mother config.xml.\n");