2013-02-22 55 views
1

我想在yii-auth模塊中使用我的佈局。但在我的佈局yii-auth設置主題

<?php echo Yii::app()->theme->baseUrl; ?> 

因爲我需要加載一些css文件和圖像。模塊yii-auth沒有設置主題,所以我得到錯誤,因爲主題「面板」沒有設置。

Yii-auth設置讓我只設置佈局,而不是主題。

我可以很容易地通過修改yii-auth模塊來設置這個,但是當yii-auth更新的時候我必須記住這個。它骯髒:)

問題是:我如何更改yii-auth的主題,而無需調整模塊/ auth文件夾?

編輯: 我的默認配置是其他然後「面板」。我不能在config/main.php中設置'theme'=>'panel'。

回答

0

正如你可以定義模塊,自定義佈局,你可以做到這一點(如文件views/layouts/panel.php):

<?php Yii::app()->theme = 'panel'; ?> 
<?php include(dirname(__FILE__).'/main.php') ?> 

將設置另一個主題,然後只用主要佈局文件。 在您的配置中,您應該將//layouts/panel設置爲您的驗證模塊的默認佈局。

您也可以對每個文件/視圖基數執行一次,有關示例實現,請參閱this file

[更新]

請看看https://github.com/schmunk42/multi-theme 可以定義每個控制器路線的一個主題。

0

在我的案例中/config/main.php設置

'appLayout' => 'webroot.themes.bootstrap.views.layouts.main', // the layout used by bootstrap theme. 

的伎倆

'auth' => array(
      'strictMode' => true, // when enabled authorization items cannot be assigned children of the same type. 
      'userClass' => 'User', // the name of the user model class. 
      'userIdColumn' => 'id', // the name of the user id column. 
      'userNameColumn' => 'username', // the name of the user name column. 
      'defaultLayout' => 'application.views.layouts.main', // the layout used by the module. 
      'appLayout' => 'webroot.themes.bootstrap.views.layouts.main', // the layout used by bootstrap theme. 
      'viewDir' => null, // the path to view files to use with this module. 
     ),