PHPackages                             mxc-commons/mxc-layoutscheme - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. mxc-commons/mxc-layoutscheme

ActiveLibrary[Templating &amp; Views](/categories/templating)

mxc-commons/mxc-layoutscheme
============================

Zend Framework 2 Module that allows to define layout schemes and apply custom layouts to routes, modules, controllers and actions.

v0.5.0(12y ago)41.2k1BSD-3-ClausePHPPHP &gt;=5.3.3

Since Jul 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/mxc-commons/MxcLayoutScheme)[ Packagist](https://packagist.org/packages/mxc-commons/mxc-layoutscheme)[ Docs](http://www.github.com/mxc-commons/MxcLayoutScheme/)[ RSS](/packages/mxc-commons-mxc-layoutscheme/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (7)Versions (7)Used By (0)

MxcLayoutScheme
===============

[](#mxclayoutscheme)

Version 0.5.0 created by Frank Hein and the mxc-commons team.

MxcLayoutScheme is part of the maxence Open Source Initiative by [maxence business consulting gmbh, Germany](http://www.maxence.de).

Introduction
------------

[](#introduction)

Did you ever want to apply a different layout phtml based on the route matched or for a particular module, controller or action? This is what MxcLayoutScheme can do for you.

MxcLayoutScheme allows to dynamically exchange the layout template used by the renderer. You define layout schemes which are a collection of rules to select layouts. Within each scheme you can assign a distinct layout to a particular route matched. Further you can define a distinct layout for each module, controller and action.

MxcLayoutScheme supports the configuration child ViewModels together with associated view templates to get rendered to captures you define.

Further, MxcLayoutScheme intercepts dispatch errors. You can apply layouts for particular error codes and http status codes the same way you do for routes and controllers.

MxcLayoutScheme provides an event interface to allow you to select the layout scheme applied at bootstrap time.

Requirements
------------

[](#requirements)

- [Zend Framework 2](https://github.com/zendframework/zf2) (latest master)

Features / Goals
----------------

[](#features--goals)

Main design goal of MxcLayoutScheme is to encapsulate the layout specific settings within the applied layout view template as far as possible. We want to achieve that within the controller action as less as possible remains to be done regarding the layout. So controller programmers can focus on the page `'content'` part of the page regardless of the target layout (which can be very different for different target platforms (JQuery, JQuery Mobile, Dojo, ... whatever).

**1. Provide the capability to assign the layout dynamically**

- based on the current route matched
- for each module
- for each controller
- for each action implemented by a controller

**2. Provide hierarchical matching of modules, controllers, actions and routes**

- route match supersedes action match
- action match supersedes controller match
- controller match supersedes module match
- module match supersedes global settings

**3. Encapsulate layout selection rules into layout schemes**

**4. Support to add child ViewModels to the layout by configuration**

**5. Allow selection of active layout scheme based on custom criteria**

- You may select the layout scheme selection in response to an event provided.

**6. Allow configuration of a global default layout for each layout scheme**

**7. Provide hooks for pre- and postprocessing**

**8. Provide a controller plugin to control scheme selection and setup of layout variables**

**9. Provide support for dispatch errors**

**10. Provide support for content view template**

In the current version you can either assign the layout variables within the controller action via `layoutScheme` controller plugin. Alternatively you may supply an event handler for pre- and postprocessing. We provide an example here.

Installation
------------

[](#installation)

### Main Setup

[](#main-setup)

#### By cloning project

[](#by-cloning-project)

1. Clone this project into your `./vendor/` directory.

#### With composer

[](#with-composer)

1. Add this project in your composer.json:

    ```
     json

     	"require": {
     		"mxc-commons/mxc-generics": "dev-master,
     		"mxc-commons/mxc-layoutscheme": "dev-master"
     	}

    ```
2. Now tell composer to download MxcLayoutScheme by running the command:

    ```
     bash

     $ php composer.phar update

    ```

#### Post installation

[](#post-installation)

1. Enabling it in your `application.config.php`file.

    ```
     php
