Fixes theme helper to have config array always available

main
Yasen Pramatarov 2025-06-16 12:22:26 +03:00
parent c9490cf149
commit a0f3e84432
1 changed files with 8 additions and 3 deletions

View File

@ -193,14 +193,19 @@ class Theme
*/
public static function include($template)
{
$themeName = self::getCurrentThemeName();
$config = self::getConfig();
global $config;
$config = $config ?? [];
$themeConfig = self::getConfig();
$themeName = self::getCurrentThemeName();
// Import all global variables into local scope
// We need this here, otherwise because this helper
// between index and the views breaks the session vars
extract($GLOBALS, EXTR_SKIP | EXTR_REFS);
// Ensure config is always available in templates
$config = array_merge($config, $themeConfig);
// For non-default themes, look in the theme directory first
if ($themeName !== 'default') {
$themePath = $config['paths']['themes'] . '/' . $themeName . '/views/' . $template . '.php';