2017 © Pedro Peláez
 

library ze-theme

ZeTheme is a Zend Framework 2 module that allows you to switch between various themes. The module does not contain any themes, but you can create your own.

image

zendexperts/ze-theme

ZeTheme is a Zend Framework 2 module that allows you to switch between various themes. The module does not contain any themes, but you can create your own.

  • Thursday, January 9, 2014
  • by ZendExperts
  • Repository
  • 8 Watchers
  • 26 Stars
  • 13,645 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 10 Forks
  • 4 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

ZeTheme

ZeTheme is a Zend Framework 2 module that allows you to switch between various themes. It allows developers to create various themes for a website and then switch between them at will., (*1)

You can define multiple folders where themes are installed and also defined adapters that help in the selection of the current theme. By default the current theme is displayed based on the configuration file, but the module allows the creation of adapters that can select the theme from the session, a database field or any other place you saved it to., (*2)

Installation / Usage

ZeTheme can be installed using Composer by simply adding the following lines to your composer.json file:, (*3)

"require": {
    "zendexperts/ze-theme": "dev-master"
}

Then run php composer.phar update and add ZeTheme in the application.config.php file under modules., (*4)

Documentation

Within the configuration file for the module you can set the default theme that should be used, the list of directories that should be search for various themes and the adapters used for selecting the current theme as listed bellow:, (*5)

'ze_theme' => array(
    'default_theme' => 'default',
    'theme_paths' => array(
        __DIR__ . '/../themes/'
    ),
    'adapters' => array(
        'ZeTheme\Adapter\Configuration',
    ),
),

To get a basic theme up and running you can just copy the default one from examples/theme folder into the themes folder or create a new one by following the tutorial bellow. Make sure that the default_theme option is set to the name of your new theme., (*6)

ZeTheme uses adapters to get the theme that should be rendered. By default the ZeTheme\Adapter\Configuration class is used to get the default theme specified in the configuration file. There is also a Session adapter that retrieves the theme from the $_SESSION['ZeTheme'] and a Route adapter that allows you to specify a different theme for each route by simply changing the your configuration to somethine similar to this:, (*7)

'ze_theme' => array(
    'default_theme' => 'default',
    'theme_paths' => array(
        __DIR__ . '/../themes/'
    ),
    'routes'=>array(
        'back'=>array('home', 'blog')
    ),
    'adapters' => array(
        'ZeTheme\Adapter\Configuration',
        'ZeTheme\Adapter\Route',
    ),
),

In this case the back theme will be used whenever the home or blog routes are matched. In all other cases the application will use the default theme., (*8)

In order to create a new theme you just need to create a folder with the name of the new theme in one of the directories specified by the theme_paths array that should contain a config.php file that should return a configuration array with the paths to the views defined in the new theme., (*9)

If you have more complex theme setup you can use dinamic theme path like so:, (*10)

'ze_theme' => array(
    'default_theme' => 'default',
    'custom_theme_path' => true,
    'theme_paths' => array(
        __DIR__ . '/../themes/{theme}/frontend/'
    ),
    ...

where of course the {theme} will be replaced with the $default_theme, (*11)

Bellow is an example of such a file:, (*12)

<?php
return array(
    'template_path_stack' => array(
        'default' => __DIR__ . '/view',
    ),
    'template_map' => array(
        'layout/layout'           => __DIR__ . '/view/layout/layout.phtml',
        'application/index/index' => __DIR__ . '/view/application/index/index.phtml',
        'error/404'               => __DIR__ . '/view/error/404.phtml',
        'error/index'             => __DIR__ . '/view/error/index.phtml', 
    ),
);

The Versions

09/01 2014

dev-master

9999999-dev https://github.com/ZendExperts/ZeTheme

ZeTheme is a Zend Framework 2 module that allows you to switch between various themes. The module does not contain any themes, but you can create your own.

  Sources   Download

New BSD

The Requires

  • php >=5.3.3

 

templating zf2 module view