Yii 2.0 Theming

Hi all,

I’m developing a multi-theme application. I wonder how I can apply a theme for my application. I tried to add

to my main.php, but I can’t see any changes when I reload my page. Do I have to change anything else ?

Thanks

When I set this line : ’

, yii will execute the applyTo() method, but this line :


if (strpos($path, $from) === 0) {

in the Theme file will always return false.

Any ideas ?

Thanks,

Change your @web/views to @app/views.




'components' => [

    'view' => [

        'theme' => [

            'pathMap' => ['@app/views' => '@webroot/themes/basic'],

            'baseUrl' => '@web/themes/basic',

        ],

    ],

],



Taken from this guide.

You may also want to check out the descriptive comments in the theme class.

Thanks so much amnah

I’m wondering how can I set the theme dynamically ?

Thanks,

Same way:




Yii::$app->view->theme->pathMap = [...];

Yii::$app->view->theme->baseUrl = ...;