2013-02-22 109 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. 
     ),