Question about layouts

Yii 1.1.6

The Controller.php component of the demo app contains this statement:

“public $layout=‘application.views.layouts.column1’;”.

The “column1.php” contains this code: “<?php $this->beginContent(‘application.views.layouts.main’); ?>”.

Why is the default layout, column1.php, redirecting to another layout, main.php, in which the contents of column1.php is placed?

column1.php is supposed to alter the main.php layout, this is why it invokes it

It allows to alter a main template without writing a template from scratch. you may regard it as a subtemplate

It just renders the view content by echoing <?php echo $content ?>

Then it calls $this->endContent();

The trick is that your column1.php generated code will replace <echo $content ?> in main layout main.php

So you can write some extra html in column1.php, then echo $content(which is the view, captured by main.php) and add some extra html after the echo as well

the endContent() call will capture all these alterations and apply them where <? echo $content ?> is placed in the MAIN main.php.

thanks very much for the explaination.

Did you find this info in the Yii documents? If so, would you point me to the reference?

This is the best I can get, and very well explained as opposed to my way:

http://www.yiiframework.com/doc/api/1.1/CContentDecorator

Thanks again.