matycz / lemo-theme
Installs: 5 149
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- laminas/laminas-dependency-plugin: ^2.0
- laminas/laminas-eventmanager: ^3.0
- laminas/laminas-mvc: ^3.0
- laminas/laminas-servicemanager: ^3.0
- laminas/laminas-stdlib: ^3.0
- laminas/laminas-view: ^2.0
Requires (Dev)
- vimeo/psalm: ~4.7.0
README
Lemo\Theme is a Zend Framework 2 module that allows you to switch between various themes. It allows you to create various themes and then switch between them. Themes can be installed in multiple folders.
The current theme can be defined in global.ini
or local.ini
for whole application. For the module you can set default theme
in module.config.php
. You can switch theme from any place in application by ServiceManager
from instance of ThemeManager
too.
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
-
cd my/project/directory
-
Create a
composer.json
file with following contents:{ "require": { "matycz/lemo-theme": ">=1.0" } }
-
Run
php composer.phar install
-
Open
my/project/directory/config/application.config.php
and add module nameLemo\Theme
into keymodules
like below:return array( ... 'modules' => array( ... 'Lemo\Theme' ... ), ... );
Installation without composer is not officially supported, and requires you to install and autoload
the dependencies specified in the composer.json
.
Documentation
In configuration files you can set the default theme that should be used, the list of directories that should be used for selecting the current theme as listed bellow:
'theme_manager' => array(
'theme' => 'default',
'theme_paths' => array(
'./theme/'
),
),
To get a basic theme up and running you can just copy the default
one from examples/theme
folder into the theme
folder in application root or create a
new one by following the tutorial bellow. Make sure that the theme
option is set the the name of your new theme.
Examples
<?php namespace Foo\Controller; use Lemo\Theme\ThemeManagerInterface; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\View\Model\ViewModel; class BarController extends AbstractActionController { /** * @var ThemeManagerInterface */ protected $themeManager; ... /** * Page with grid example * * @return ViewModel */ public function indexAction() { // Example1 - Set new theme with name foo $this->getThemeManager()->setTheme('foo'); // Example 2 - Set new theme with name foo $this->getServiceLocator()->get('ThemeManager')->setTheme('foor'); return new ViewModel(array( ... )); } ... /** * @param ThemeManagerInterface $themeManager * @return BarController */ public function setThemeManager(ThemeManagerInterface $themeManager) { $this->themeManager = $themeManager; return $this; } /** * @return ThemeManagerInterface */ public function getThemeManager() { return $this->themeManager; } }
<p class="current-theme"><?= $this->theme() ?></p>