line
$themeActive = Theme::getActiveTheme()->getDirName();
gets theme name only from .env
If you set another theme in /cms/themes , then $themeActive will still get name from .env
Is this normal behavior of Theme::getActiveTheme()
?
line
$themeActive = Theme::getActiveTheme()->getDirName();
gets theme name only from .env
If you set another theme in /cms/themes , then $themeActive will still get name from .env
Is this normal behavior of Theme::getActiveTheme()
?
Yes, Theme::getActiveTheme()
by default returns the theme set in the configuration, typically defined by the active_theme key in config/cms.php
, which in turn can be overridden by the .env
file setting CMS_ACTIVE_THEME
.
This is normal behavior. If you place a new theme in /themes
but do not update the active_theme
setting or use the php artisan theme:use themename
command, Theme::getActiveTheme()
will continue to return the one defined in .env
or config.
To switch themes programmatically or through Artisan, use:
php artisan theme:use your-new-theme
This will not work When switching themes in the theme manager.
If the user switches or clones a theme in the theme manager, then plugins using Theme::getActiveTheme()
will return incorrect data.
The rainlab.sitemap plugin contains the code
\plugins\rainlab\sitemap\handlers\SitemapHandler.php
public function sitemap()
{
$themeActive = Theme::getActiveTheme()->getDirName();
try {
$definition = Definition::where('theme', $themeActive)->firstOrFail();
}
catch (ModelNotFoundException $e) {
Log::info(trans('rainlab.sitemap::lang.definition.not_found'));
return Response::make(View::make('cms::404'), 404);
}
return Response::make($definition->generateSitemap())
->header('Content-Type', 'application/xml');
}
it will ignore the list of pages of the customized theme