I am trying to do multi theme in advanced-yii2. I tried a lot of way for this but it doesn't work I can't understand. Firstly, I added this to "frontend/config/main.php";
'view' => [
'theme' => [
'pathMap' => [
'@app/views' => [
'@webroot/themes/demo/views',
]
],
],
],
and it doesn't work, then I tried to creating a new view class for frontend, for example:
namespace frontend\components;
class NewsView extends \yii\web\View {
function init() {
\Yii::$app->view->viewPath = '@webroot/themes';
parent::init();
}
}
and added in config.php
'view' => [
'class' => 'frontend\components\NewsView',
but it doesn't work too.
What should I do?
You can redefine getViewPath method at your base controller. Like
public function getViewPath()
{
return Yii::getAlias('@frontend/views/newview');
}
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