Support themes middleware that allows to switch between themes. It is generally designed for Zend Expressive.
composer require atukai/theme-middleware
Zend Expressive:
Include config from ConfigProvider.php. Recommend to use [Expressive Configuration Manager] (https://github.com/mtymek/expressive-config-manager)
$configManager = new ConfigManager([
...,
\At\Theme\ConfigProvider::class,
]);
Create themes folder.
./themes
Configure your settings.
'themes' => [
'theme_paths' => [
__DIR__ . '/../themes/'
],
];
Other frameworks:
You should implement Zend\Expressive\Template\TemplateRendererInterface
and
put it under TemplateRendererInterface::class
key into your container
It uses resolvers to detect theme name that should be currently used for rendering.
By default the At\Theme\Resolver\ConfigurationResolver
is used to get theme specified in config.
You can add one or more resolvers with priority.
'themes' => [
'paths' => [
__DIR__ . '/../themes/'
],
'default_theme' => 'default',
'resolvers' => [
\At\Theme\Resolver\HttpRequestResolver::class => 20,
],
];
'themes' => [
'paths' => [
__DIR__ . '/../themes/'
],
'default_theme' => 'default',
'resolvers' => [
\At\Theme\Resolver\HttpRequestResolver::class => 20,
],
'assets' => [
'paths' => [__DIR__ . '/../themes/default/assets'],
'cache_dir' => __DIR__ . '/../public'
]
];