Hello,
I am new to framework (only a few days of playing around). I got a bot confused how layouts work. I hope you
guys can help me out.
I have my main site setup and under it I created a module I added following to config file:
'modules'=>array(
'adminTest'=>array('layout'=>'admin')
),
Under modules/adminTest/views/layouts I created a modified copy of the main.php of the main site layout.
in index.php under module I added following code:
<p>
Layout Path <?php echo $this->module->layoutPath ?> <br/>
Layout <?php echo $this->module->layout ?>
</p>
the output looks like:
Layout Path {removed}/protected/modules/adminTest/views/layouts
Layout admin
but the page still uses main.php layout form main site. What am I missing?
I am using code from svn 1.1.3-dev
thanks in advance for any idea you can give me. I feel like I am stuck. I want to keep module related
layout within that module
Page 1 of 1
mudule and view layout
#2
Posted 05 July 2010 - 09:22 PM
$this->layout = "admin";
$this->render('index');
try in your action!
$this->render('index');
try in your action!
#3
Posted 05 July 2010 - 10:28 PM
that did worked! Do I have to init this in each action for each comptroller? How come the global property
did not work? Does controller have a init routine that executed before each action that I can use?
did not work? Does controller have a init routine that executed before each action that I can use?
#4
Posted 06 July 2010 - 08:39 AM
Yes of corse you can.
Instead of writing
If all your controllers in a module have to share some properies, you can set them in AdminTestModule::beforeControllerAction
Instead of writing
$this->layout = "admin";in the action you can use
public $layout='admin';at top of your class.
If all your controllers in a module have to share some properies, you can set them in AdminTestModule::beforeControllerAction
#5
Posted 06 July 2010 - 09:25 AM
but why the module property does not get propagated to the controller level? According to doc it should.
Also if action 'a' will have 'public $layout= 'admin'' and I am actually activating action b then my init
will never gets hit?
Also if action 'a' will have 'public $layout= 'admin'' and I am actually activating action b then my init
will never gets hit?
Share this topic:
Page 1 of 1

Help












