Giter Club home page Giter Club logo

zf-themes's Introduction

ZF-Themes

Zend Framework 2 (ZF2) theme manager

Add the following line to composer.json of your application

"require": {
    "shadowfax/zf-themes": "dev-master"
}

In the index.php change

Zend\Mvc\Application::init(require 'config/application.config.php')->run();

with

Themes\Mvc\Application::init(require 'config/application.config.php')->run();

This will load the ThemeManager service.

When creating a new module simply implement Themes\ModuleManager\Feature\ThemeProviderInterface

...

use Themes\ModuleManager\Feature\ThemeProviderInterface;

...

class Module implements ThemeProviderInterface
{

    ...
    
    public function getDir()
    {
    	return __DIR__;
    }
    
    public function getNamespace()
    {
    	return __NAMESPACE__;
    }
    
    ...
    
}

The themes should be in a subfolder called themes inside the module directory. There should be, atleast, a theme called default.

Example tree:

  • themes
    • default
    • my_new_theme

The layout file layout.phtml should be in the root of the theme, all the rest works just like Zend Framework's view folder.

Assets (CSS, JS, Images,...) can be stored in the assets folder under the theme. Here is an example entry for the default module.

  • default
    • assets
      • css
        • layout.css
        • bootstrap.css
      • js
        • jquery.js
    • application
      • index
        • index.phtml
    • layout.phtml

The module makes a route named assets. The url to assets is

/assets/:modules/*

Where * is the relative path to the actual asset.

Making a port of a Zend Framework 2 application to a theme based applications should be a breeze as you only have to change the name of view forlder to default, move it into a folder named themes and move the layout file and you are ready.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.