PHPackages                             dmstr/yii2-themed-view-path-behavior - 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. dmstr/yii2-themed-view-path-behavior

ActiveYii2-behavior[Templating &amp; Views](/categories/templating)

dmstr/yii2-themed-view-path-behavior
====================================

behavior to easily set view pathMaps via yii2 theme

1.1.0(3y ago)08.6k—8.3%1BSD-3-ClausePHP

Since Aug 19Pushed 3y ago3 watchersCompare

[ Source](https://github.com/dmstr/yii2-themed-view-path-behavior)[ Packagist](https://packagist.org/packages/dmstr/yii2-themed-view-path-behavior)[ RSS](/packages/dmstr-yii2-themed-view-path-behavior/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

yii2-themed-view-path-behavior
==============================

[](#yii2-themed-view-path-behavior)

Behavior to easily set additional view paths via [yii2 theme pathMap](https://www.yiiframework.com/doc/guide/2.0/en/output-theming).

Config options see: [ThemedViewPathBehavior.php](./src/ThemedViewPathBehavior.php)

ThemedViewPathBehavior can be attached to:

- controllers
- modules
- widgets

path order
----------

[](#path-order)

As the yii\\base\\Theme will use the first matching view file from the list of given paths, the order within the generated pathMap is relevant.

see: [guide: theme-inheritance](https://www.yiiframework.com/doc/guide/2.0/en/output-theming#theme-inheritance)

In the context of this behavior, there are basically 2 scenarios:

*Should the owners default viewPath be the first or the last directory where yii will search for view files?*

The `pathOrder` property can be used to define the order:

valueeffectThemedViewPathBehavior::MAP\_APPENDthe owners default viewPath will be the **first** dir in mapThemedViewPathBehavior::MAP\_PREPENDthe owners default viewPath will be the **last** dir in mapused Events
-----------

[](#used-events)

According to the type of the `owner` the behavior attach itself to events:

ownereventcontrollerController::EVENT\_BEFORE\_ACTIONmoduleModule::EVENT\_BEFORE\_ACTIONwidgetWidget::EVENT\_BEFORE\_RUNExamples:
---------

[](#examples)

### Extend viewPath for one controller

[](#extend-viewpath-for-one-controller)

Task:

- You have installed the dmstr/yii2-active-record-search
- You want to integrate a SearchGroupController to manage the SearchGroups from active-record-search module within another module e.g. admin
- You want to overwrite some (but not all) default views used from within \\dmstr\\activeRecordSearch\\controllers\\SearchGroupController

Solution:

- set active-record-search module view path as fallback via behavior config.

```
