Skip to content

Commit

Permalink
Ensure proper defaults used on initial load
Browse files Browse the repository at this point in the history
  • Loading branch information
sbulen committed Aug 24, 2022
1 parent bce610f commit 9a8fcf8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
21 changes: 17 additions & 4 deletions dist/index.template.php
Expand Up @@ -40,7 +40,7 @@
*/
function template_init()
{
global $settings, $txt, $context;
global $settings, $txt, $context, $smcFunc;

/* $context, $options and $txt may be available for use, but may not be fully populated yet. */

Expand Down Expand Up @@ -103,9 +103,22 @@ function template_init()
)
);

// If vars were never saved, then they don't exist in $settings yet... Fix that...
// Kinda important or bad things happen right after install...
if (empty($settings['cc_background']))
// If vars were never saved, then they don't exist in $settings yet. Fix that.
// Kinda important or bad things happen right after install.
// Need to actually check the Themes table, because sometimes CC defaults are inherited
// from the default theme - don't know if they're for this theme or not...
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}themes
WHERE id_theme = {int:id_theme}
AND variable LIKE {string:color_vars}',
array(
'id_theme' => $settings['theme_id'],
'color_vars' => 'cc_%'
)
);
list($color_count) = $smcFunc['db_fetch_row']($request);
if (empty($color_count))
foreach($settings['color_palettes']['default'] as $ix => $var)
$settings['cc_' . $ix] = $var;

Expand Down
2 changes: 1 addition & 1 deletion dist/readme.txt
Expand Up @@ -28,4 +28,4 @@ This theme is, in part, a demo. Theme designers should feel free to borrow code

[b]Releases:[/b]
- v1.4 Initial release

- v1.5 Ensure proper defaults used on initial load
2 changes: 1 addition & 1 deletion dist/theme_info.xml
Expand Up @@ -3,7 +3,7 @@
<!-- For the id, always use something unique - put your name, a colon, and then the package name. -->
<id>shawnb61:Cotton Candy</id>
<!-- The theme's version, please try to use semantic versioning. -->
<version>1.4</version>
<version>1.5</version>
<!-- Install for, the SMF versions this theme was designed for. Uses the same wildcards used in the packager manager. This field is mandatory. -->
<install for="2.1 - 2.1.99" />
<!-- Theme name, used purely for aesthetics. -->
Expand Down

0 comments on commit 9a8fcf8

Please sign in to comment.