Showing posts with label php Cannot change Yii2 theme. Show all posts
Showing posts with label php Cannot change Yii2 theme. Show all posts

Cannot change Yii2 theme

Wednesday, November 4, 2015

I have installed Yii2 advanced application, and now I'm trying to change frontend theme to this: http://yii2.themefactory.net/theme/40/interior . I tried to do it using the instructions from the website themefactory, and instructions from the official Yii2 documentation ( http://www.yiiframework.com/doc-2.0/guide-output-theming.html ), but I still can't do it.



I put this theme in a folder /myyii2folder/frontend/themes and set the following changes to the file /myyii2folder/frontend/config/main.php (I show the entire file):



<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);

return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'view' => [
'layout' => '@app/themes/interior/layouts'
'theme' => [
'basePath' => '@app/themes/interior',
'baseUrl' => '@app/themes/interior',
'pathMap' => [
'@app/views' => '@app/themes/interior',
],
],
],
],

'params' => $params,
];


This is structure of theme:



themes
└── interior
   ├── files
   │   ├── main_style.css
   │   └── theme
   │   ├── banner-landing.jpg
   │   ├── banner-short.jpg
   │   ├── banner-splash.jpg
   │   ├── banner-tall.jpg
   │   ├── button_highlight.png
   │   ├── button_large_highlight.png
   │   ├── button_large.png
   │   ├── button.png
   │   ├── facebook-h.png
   │   ├── facebook.png
   │   ├── field.png
   │   ├── header-wrap-bg.png
   │   ├── img.png
   │   ├── linkedin-h.png
   │   ├── linkedin.png
   │   ├── main_style.css
   │   ├── nav-left-bg.png
   │   ├── nav-right-bg.png
   │   ├── rounded.png
   │   ├── rss-h.png
   │   ├── rss.png
   │   ├── searchForm-bg.png
   │   ├── social-grey.png
   │   ├── social-midgrey.png
   │   ├── twitter-h.png
   │   └── twitter.png
   ├── layouts
   │   └── main.php
   └── site
   ├── about.php
   ├── contact.php
   ├── error.php
   ├── index.php
   ├── login.php
   ├── requestPasswordResetToken.php
   ├── resetPassword.php
   └── signup.php


Now I see a blank page when loading my site. If I remove layout section in components => view, I see the default Yii2 theme without any changes.



How I can fix this?

Cannot change Yii2 theme

I have installed Yii2 advanced application, and now I'm trying to change frontend theme to this: http://yii2.themefactory.net/theme/40/interior . I tried to do it using the instructions from the website themefactory, and instructions from the official Yii2 documentation ( http://www.yiiframework.com/doc-2.0/guide-output-theming.html ), but I still can't do it.



I put this theme in a folder /myyii2folder/frontend/themes and set the following changes to the file /myyii2folder/frontend/config/main.php (I show the entire file):



<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);

return [
'id' => 'app-frontend',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'view' => [
'layout' => '@app/themes/interior/layouts'
'theme' => [
'basePath' => '@app/themes/interior',
'baseUrl' => '@app/themes/interior',
'pathMap' => [
'@app/views' => '@app/themes/interior',
],
],
],
],

'params' => $params,
];


This is structure of theme:



themes
└── interior
   ├── files
   │   ├── main_style.css
   │   └── theme
   │   ├── banner-landing.jpg
   │   ├── banner-short.jpg
   │   ├── banner-splash.jpg
   │   ├── banner-tall.jpg
   │   ├── button_highlight.png
   │   ├── button_large_highlight.png
   │   ├── button_large.png
   │   ├── button.png
   │   ├── facebook-h.png
   │   ├── facebook.png
   │   ├── field.png
   │   ├── header-wrap-bg.png
   │   ├── img.png
   │   ├── linkedin-h.png
   │   ├── linkedin.png
   │   ├── main_style.css
   │   ├── nav-left-bg.png
   │   ├── nav-right-bg.png
   │   ├── rounded.png
   │   ├── rss-h.png
   │   ├── rss.png
   │   ├── searchForm-bg.png
   │   ├── social-grey.png
   │   ├── social-midgrey.png
   │   ├── twitter-h.png
   │   └── twitter.png
   ├── layouts
   │   └── main.php
   └── site
   ├── about.php
   ├── contact.php
   ├── error.php
   ├── index.php
   ├── login.php
   ├── requestPasswordResetToken.php
   ├── resetPassword.php
   └── signup.php


Now I see a blank page when loading my site. If I remove layout section in components => view, I see the default Yii2 theme without any changes.



How I can fix this?