As per YII documentation, Iam using variable "$content" in layouts. I came to know that it is inserting two extra divs "container" and "content" before actual data. Actually it is boxing data with these two divs.
Can some one guide me how to remove these two divs.
// As you may notice, the content of the ‘columm1’ layout (which contains the content of the view) will also be passed to another layout file that is ‘main.php’.
If you don’t like the “extra” 2 divs, you may delete them.
But in that case you should provide an appropriate set of CSS files on your own, or you will get somewhat broken outputs on the screen, because the default CSS files of Yii framework refer to the "container" and "content" divs to define the screen layouts.
Thanks for your reply. I have studied it but I am still confused about the default layout. In the demo application I find this code in the SiteController.php:
/**
* This is the default 'index' action that is invoked
* when an action is not explicitly requested by users.
*/
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index');
}
This implies that the default layout is main.php and not column1.php. I have, perhaps erroneously, edited the main.php to suit my needs and edited index.php to contain the desired content.
It is almost as though my application is using my modified main.php layout, rendering column.php layout inside main.php layout and inserting my index.php into the column1.php layout.
I search through the "Definative Guide to Yii" and found this statement in the layout section "By default, the view script protected/views/layouts/main.php is used as the layout.".
There should be a difference between the layout structures of the demo application (which you’ve been reading) and the skeleton application created by yiic.
demo : view - main
skeleton : view - column1 - main
And there’s no harm in abandoning the layout structure of the skeleton. You don’t have to stick to the “view - (column1|column2) - main” scheme, and it’s okay to do it as you like, only if you are willing to modify the default CSS files or write them on your own.