Difference between #3 and #4 of
Fixing extensions without modifying their code

Revision #4 has been created by schmunk on Mar 6, 2013, 10:39:24 AM with the memo:

added section about "Theme switching for backend module views"
« previous (#3)

Changes

Title unchanged

Fixing extensions without modifying their code

Category unchanged

Tips

Yii version unchanged

Tags changed

paths, extensions, alias, aliases, extending, behavior, themes, layouts

Content changed

[...]
Since the methods from WebUser are now available for RWebUser you can use the same class in both modules.

**Note: This way is not possible for all cases, you can not override existing methods with a behavior, eg. `yii-rights` overrides checkAccess() and other methods of CWebUser.**


 
Theme switching for backend module views
 
----------------------------------------
 
 
Most modules don't allow you to set a theme for it's views, but usually you can define a custom layout file for the module.
 
 
As you can define a custom layout for the module you can do this (eg. file `views/layouts/mytheme.php`):
 
 
    Yii::app()->theme = 'mytheme';
 
    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/mytheme` as the default layout for your module.
 
 
You can also do this one a per file/view bases, see [this file](https://github.com/schmunk42/p3bootstrap/blob/9f0df57e2f97639ada612ce724db6408149b4f13/views/rights/default/index.php) for a sample implementation.
 
 
 
 
------------ *These techniques are used in [Phundament](http://phundament.com) to ensure compatibility and minimize additional maintainance and complexity.* -- https://github.com/phundament/app/wiki/Extensions
6 0
10 followers
Viewed: 11 417 times
Version: 1.1
Category: Tips
Written by: schmunk
Last updated by: schmunk
Created on: Feb 28, 2013
Last updated: 5 years ago
Update Article

Revisions

View all history