How To Create Own Default Layout

Hi, I am just confuse how the yii call the default layout main.php ?..can i also create my own layout and set it as default?

Thank you in advance.

I think the actual default layout is ‘column1’. If you look in it, at the top there is a $this->beginContent(’//layouts/main’). This is where main.php is included.

You can create as many layouts as you want. Mostly they are just changing what goes inside the page, ‘main.php’ is used to create the common html for all pages. Inside the main.php there is a line

<?php echo $content; ?>

this is important. This is where you page content will actually be placed.

If you want to ‘make your own’ main layout, just make a copy of it, call it ‘myMain.php’, go into the columnX layouts and the reference to ‘main’ to ‘myMain’. As for setting a default layout: for the whole app, it’s in the ‘Controller.php’ in components. You change for all action in one controller at the top. You can change for just one action within the action. At the controller level it’s

public $layout = '//layouts/column1';

At the action level it’s

$this->layout = '//layouts/column2';

Be advised that the ‘//’ at the beginning “look in app/views/layouts”. Location of layouts can be different if using a Module or Theme.

Thank you for the quick reply…Okay i will try…Thank you so much :)