2014-11-19 2 views
2

나는 advanced-yii2에서 멀티 테마를하려고합니다. 나는 이것을 위해 많은 방법을 시도했지만 그것이 작동하지 않는다. 나는 이해할 수 없다. 먼저 "frontend/config/main.php"에 추가했습니다.Yii2에서 기본보기 경로를 변경하는 방법은 무엇입니까?

  'view' => [ 
       'theme' => [ 
       'pathMap' => [ 
        '@app/views' => [ 
         '@webroot/themes/demo/views', 

        ] 
       ], 
       ], 
      ], 

내가 예를 들어, 프론트 엔드의 새로운 뷰 클래스를 만드는 시도 후이 작동하지 않았다

namespace frontend\components; 

class NewsView extends \yii\web\View { 

    function init() { 
    \Yii::$app->view->viewPath = '@webroot/themes'; 
    parent::init(); 
    } 

} 

'view' => [ 
     'class' => 'frontend\components\NewsView', 

config.php를 추가하지만 그것을 너무 효과가 없습니다.

어떻게해야합니까?

+0

나는 이것을 잘못 생각했다. SiteController는 "index.tpl"로 렌더링하려고하는데, "index.tpl"이 없다. :) – Serhat

답변

5

기본 제어기에서 getViewPath 메소드를 다시 정의 할 수 있습니다. Like

public function getViewPath() 
{ 
    return Yii::getAlias('@frontend/views/newview'); 
} 
관련 문제