Yii2 Theme Integration ?
'view' => [
'theme' => [
'pathMap' => ['@app/views' => '@app/admin/views'],
'baseUrl' => '@web/admin',
],
],
Hope you are using the advanced template
add a folder themes in the backend folder
make a subfolder with the theme name and make sure you have the layouts folder in that folder
ie your new layout folder path will be
backend/themes/themefoldername/layouts
in the folder backend/config/main.php
'components' => [
'view' => [
'theme' => [
'basePath' => '@backend/themes/themefoldername',
'baseUrl' => '@backend/themes/themefoldername',
'pathMap' => [
'@backend/views' => '@backend/themes/themefoldername',
],
],
],...
if you want to keep it in the web folder also you can do that,but make sure you change the path accordingly
In advance template there is separate configuration for frontend and backend theme integration.
Frontend theme integration => "frontend/config/main.php" file :
'components' => [
'view' => [
'theme' => [
'pathMap' => [
'@frontend/views' => '@themes/frontend/views', // need to // set alias first in your bootstrap.php file
],
],
],
],
Backend theme integration => "backend/config/main.php" file :
'components' => [
'view' => [
'theme' => [
'pathMap' => [
'@backend/views' => '@themes/backend/views', // need to set // alias first in your "common/config/bootstrap.php" file
],
],
],
],
While coding take care of comments and directory paths and no need to write baseUrl or basePath.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With