diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index d82bf9a71..915ccaacd 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -58,6 +58,7 @@ class Theme $theme = new static; $theme->setDirName($dirName); $theme->registerHalyconDatasource(); + return $theme; } @@ -133,6 +134,7 @@ class Theme public function isActiveTheme() { $activeTheme = self::getActiveTheme(); + return $activeTheme && $activeTheme->getDirName() == $this->getDirName(); } @@ -374,7 +376,12 @@ class Theme */ public function getPreviewImageUrl() { - $previewPath = '/assets/images/theme-preview.png'; + $previewPath = $this->getConfigValue('preview'); + + if (!$previewPath) { + $previewPath = '/assets/images/theme-preview.png'; + } + if (File::exists($this->getPath().$previewPath)) { return Url::asset('themes/'.$this->getDirName().$previewPath); } @@ -390,6 +397,7 @@ class Theme { self::$activeThemeCache = false; self::$editThemeCache = false; + Cache::forget(self::ACTIVE_KEY); Cache::forget(self::EDIT_KEY); } diff --git a/modules/cms/classes/theme/fields.yaml b/modules/cms/classes/theme/fields.yaml index 7b1a1286d..fb5ee6414 100644 --- a/modules/cms/classes/theme/fields.yaml +++ b/modules/cms/classes/theme/fields.yaml @@ -45,3 +45,10 @@ tabs: code: label: cms::lang.theme.code_label placeholder: cms::lang.theme.code_placeholder + span: auto + + preview: + label: cms::lang.theme.preview_label + placeholder: cms::lang.theme.preview_placeholder + default: '/assets/images/theme-preview.png' + span: auto diff --git a/modules/cms/lang/en/lang.php b/modules/cms/lang/en/lang.php index 5d9aee367..7f51a8055 100644 --- a/modules/cms/lang/en/lang.php +++ b/modules/cms/lang/en/lang.php @@ -11,14 +11,14 @@ return [ 'error_deleting' => "Error deleting the template file ':name'. Please check write permissions.", 'delete_success' => 'Templates deleted: :count.', 'file_name_required' => 'The File Name field is required.', - 'safe_mode_enabled' => 'Safe mode is currently enabled.', + 'safe_mode_enabled' => 'Safe mode is currently enabled.' ], 'dashboard' => [ 'active_theme' => [ 'widget_title_default' => 'Website', 'online' => 'Online', 'maintenance' => 'In maintenance', - 'manage_themes' => 'Manage themes', + 'manage_themes' => 'Manage themes' ] ], 'theme' => [ @@ -45,6 +45,8 @@ return [ 'homepage_placeholder' => 'Website URL', 'code_label' => 'Code', 'code_placeholder' => 'A unique code for this theme used for distribution', + 'preview_label' => 'Preview', + 'preview_placeholder' => 'The path of theme preview image.', 'dir_name_label' => 'Directory name', 'dir_name_create_label' => 'The destination theme directory', 'theme_label' => 'Theme', @@ -88,14 +90,14 @@ return [ 'dir_name_taken' => 'Desired theme directory already exists.', 'find_more_themes' => 'Find more themes', 'saving' => 'Saving theme...', - 'return' => 'Return to themes list', + 'return' => 'Return to themes list' ], 'maintenance' => [ 'settings_menu' => 'Maintenance mode', 'settings_menu_description' => 'Configure the maintenance mode page and toggle the setting.', 'is_enabled' => 'Enable maintenance mode', 'is_enabled_comment' => 'Select the page to show when maintenance mode is activated.', - 'hint' => 'Maintenance mode will display the maintenance page to visitors who are not signed in to the back-end area.', + 'hint' => 'Maintenance mode will display the maintenance page to visitors who are not signed in to the back-end area.' ], 'page' => [ 'not_found_name' => "The page ':name' is not found", diff --git a/modules/cms/lang/hu/lang.php b/modules/cms/lang/hu/lang.php index 4a6f7d663..49e7eab1c 100644 --- a/modules/cms/lang/hu/lang.php +++ b/modules/cms/lang/hu/lang.php @@ -45,6 +45,8 @@ return [ 'homepage_placeholder' => 'A honlap webcíme', 'code_label' => 'Kód', 'code_placeholder' => 'Egyedi azonosító ehhez a témához', + 'preview_label' => 'Előnézet', + 'preview_placeholder' => 'A téma előnézeti képének elérési útvonala.', 'dir_name_label' => 'Könyvtár', 'dir_name_create_label' => 'A célkönyvtár', 'theme_label' => 'Téma',