Skip to content

atukai/theme-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Theme Middleware

Support themes middleware that allows to switch between themes. It is generally designed for Zend Expressive.

Installation

composer require atukai/theme-middleware

Usage

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

Resolvers

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,
    ],
];

Assets

'themes' => [
    'paths' => [
         __DIR__ . '/../themes/'        
    ],
    'default_theme' => 'default',
    'resolvers' => [
        \At\Theme\Resolver\HttpRequestResolver::class => 20,
    ],
    'assets' => [
        'paths' => [__DIR__ . '/../themes/default/assets'],
        'cache_dir' => __DIR__ . '/../public'
    ]
];

About

Theme Supporting Middleware

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages