Different UI layout for different levels of users in yii

I am new to Yii. I am developing a system with YII framework in PHP. How can I have a different layout for another module? I want module A to have interface A, module B with interface B. But what I know is that entering the interface is the same for entering all modules. Can anyone give me some light?

Update:

I found one way which should include:

$this->layout = $layout;

      

for the action function inside the controller before rendering the page. However, I have found that this is not as efficient as with every action I need to repeat. Is there a way we can do the customization in the config / main.php page? probably from this side:

'modules'=>array(
     'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'123',
        'generatorPaths' => array('bootstrap.gii'),
     ),          

     'admin',
     'consultant',
     'client',
),

      

+3


source to share


2 answers


You can set variables for your module config

like this:

'modules'=>array(
     'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'123',
        'generatorPaths' => array('bootstrap.gii'),
     ),          

     'admin' => array(
        'layout' => 'your_layout' //The layout for this module
     ),
     'consultant',
     'client',
),

      



This way you can implement a default layout for each individual module. No need to add methods and variables controller

.

See the docs for more details: here and here

+1


source


try this:



class YourController extends Controller {

    public $layout = 'your_layout';

}

      

0


source







All Articles