1

yii-authモジュールで自分のレイアウトを使用したい。しかし、そのレイアウトでは私は持っています

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

いくつかのcssファイルと画像をロードする必要があるためです。モジュールyii-authにはテーマが設定されていないため、テーマ「パネル」が設定されていないためエラーが発生します。

Yii-auth設定では、テーマではなくレイアウトのみを設定できます。

yii-authモジュールを変更することでこれを簡単に設定できますが、yii-authの更新中にこれについて覚えておく必要があります。それは汚い :)

問題は、modules / authフォルダーを教えずにyii-authのテーマを変更するにはどうすればよいですか?

編集:私のデフォルト設定は「パネル」以外です。config/main.phpで「theme」=>「panel」を設定できません。

4

2 に答える 2

0

モジュールのカスタムレイアウトを定義できるので、これを行うことができます(例: file views/layouts/panel.php):

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

別のテーマを設定し、メイン レイアウト ファイルのみを使用します。//layouts/panel設定で、認証モジュールのデフォルト レイアウトとして設定する必要があります。

ファイル/ビューベースごとにこれを行うこともできます。サンプル実装については、このファイルを参照してください。

[アップデート]

https://github.com/schmunk42/multi-themeをご覧ください 。コントローラ ルートごとにテーマを定義できます。

于 2013-03-06T10:25:24.457 に答える
0

私の場合の設定では

    '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.
        ),
于 2013-10-13T16:31:50.897 に答える