uniqby/yii2-smart-layout

Smart Layout behavior for Yii framework 2.

Installs: 269

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

0.3 2014-12-19 16:06 UTC

This package is not auto-updated.

Last update: 2019-10-09 03:04:16 UTC


README

Yii2 Smart Layout behavior makes the theming of your application so simple

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require uniqby/yii2-smart-layout "dev-master"

or add

"uniqby/yii2-smart-layout": "dev-master"

to the require section of your composer.json

Usage

Configure Smart Layout behavior in common config:

'view' => [
	'as smartLayout' => [
    	'class' => \uniqby\smartLayout\Behavior::className(),
	]
]

Info

Component searches for the layout file relative to the current theme, module, controller and action.

$pathMaps = $controller->view->theme->pathMap;
if (is_array($pathMaps) && !empty($pathMaps)) {
	foreach ($pathMaps as $path) {
		if ($moduleId !== null) {
			$layouts[] = "{$path}/{$moduleId}/layouts/{$controllerId}_{$actionId}";
			$layouts[] = "{$path}/{$moduleId}/layouts/{$controllerId}";
			$layouts[] = "{$path}/{$moduleId}/layouts/main";
		} else {
			$layouts[] = "{$path}/layouts/{$controllerId}_{$actionId}";
			$layouts[] = "{$path}/layouts/{$controllerId}";
			$layouts[] = "{$path}/layouts/main";
		}
	}
}

Author

Alexander Sazanovich, e-mail: alexander@uniq.by