【问题标题】:yii-auth set themeyii-auth 设置主题
【发布时间】:2013-02-08 05:42:34
【问题描述】:

我想在 yii-auth 模块中使用我的布局。但在那个布局中我有

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

因为我需要加载一些 css 文件和图像。模块 yii-auth 没有设置主题,所以我收到错误,因为主题“面板”没有设置。

Yii-auth 设置让我只设置布局,而不是主题。

我可以通过修改 yii-auth 模块轻松设置它,但是当 yii-auth 更新时我必须记住这一点。它很脏:)

问题是:如何在不学习 modules/auth 文件夹的情况下更改 yii-auth 的主题?

编辑: 我的默认配置不是“面板”。我无法在 config/main.php 中设置“主题”=>“面板”。

【问题讨论】:

    标签: authentication layout module yii themes


    【解决方案1】:

    因为您可以为模块定义自定义布局,所以您可以这样做(例如文件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 您可以为每个控制器路由定义一个主题。

    【讨论】:

      【解决方案2】:

      在我的情况下设置

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

      在 /config/main.php 中成功了

       '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.
              ),
      

      【讨论】:

        猜你喜欢
        • 2017-07-13
        • 1970-01-01
        • 2014-07-11
        • 1970-01-01
        • 1970-01-01
        • 2022-01-27
        • 2014-03-15
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多