Skip to content

MsViewElements is simple ZF3 module for managing layout variables from module configs

Notifications You must be signed in to change notification settings

mstrychalski/MsLayoutVariables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

MsLayoutVariables

Created by Michał Strychalski

Introduction

MsLayoutVariables is simple Module, that allows you to set layout variables in module configs. Usefull for hiding or rendering particular elements in layout, depends on controller or module.

Installation using Composer

$ composer require mstrychalski/ms-layout-variables

Usage

Layout variables can be used in various ways, it can be limited for Action only, Module, Controller or even whole application.

Whole application

'layout_variables' => [
        'default' => [
            'showMenu' => false,
            'pageTitle' => 'Awesome title',
            'someArray' => [0,1,2,3]
        ]
    ],

Limited to Module

'layout_variables' => [
        'Application' => [
            'showMenu' => false,
            'pageTitle' => 'Awesome title',
            'someArray' => [0,1,2,3]
        ]
    ],

Limited to Controller in local namespace

'layout_variables' => [
        Controller\IndexController::class => [
            'default' => [
                'showMenu' => false,
                'pageTitle' => 'Awesome title',
                'someArray' => [0,1,2,3]
            ]
        ]
    ],

Or somewhere else

'layout_variables' => [
        \Blog\Controller\IndexController::class => [
            'default' => [
                'showMenu' => false,
                'pageTitle' => 'Awesome title',
                'someArray' => [0,1,2,3]
            ]
        ]
    ],

Limited to Action

'layout_variables' => [
        Controller\IndexController::class => [
            'index' => [
                'showMenu' => false,
                'pageTitle' => 'Awesome title',
                'someArray' => [0,1,2,3]
            ]
        ]
    ],

And now you can use it in your layout:

<?php if($this->showMenu !== false) ?>
    <div class="awesomeMenu"></div>
<?php endif; ?>

This is all, happy haking

About

MsViewElements is simple ZF3 module for managing layout variables from module configs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages