kabra
kabra

Reputation: 1316

yii-auth set theme

I want use in yii-auth module my layout. But in that layout i have

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

because i need load some css files and images. Module yii-auth doesnt have theme set, so i get error because theme "panel" is not set.

Yii-auth settings let me set only layout, not theme.

I can easy set this by modify yii-auth module, but then i have to remember about this while yii-auth update. Its dirty :)

The question is: How can i change theme for yii-auth without tuching modules/auth folder?

Edit: My default config is other then "panel". I cant set 'theme'=>'panel' in config/main.php.

Upvotes: 1

Views: 619

Answers (2)

user 1007017
user 1007017

Reputation: 391

In my case setting

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

in /config/main.php did the trick

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

Upvotes: 0

schmunk
schmunk

Reputation: 4708

As you can define a custom layout for the module you can do this (eg. file views/layouts/panel.php):

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

Which will set another theme and then just use the main layout file. In your config you should set //layouts/panel as the default layout for your auth module.

You can also do this one a per file/view bases, see this file for a sample implementation.

[UPDATE]

Please have a look at https://github.com/schmunk42/multi-theme You can define a theme per controller route.

Upvotes: 0

Related Questions