Nested layouts...

… are possible in Yii?

Thanks :slight_smile:

Yes. Assume you have a view which uses layout A that is nested in another layout B. When rendering the view, you should set its layout to be A. Inside A, you use the following:



<?php $this->beginContent('/path/to/layoutB'); ?>


stuff for layout A


<?php echo $content; ?> this is from the view


stuff for layout A


<?php $this->endContent(); ?>


In layout B, you just need to echo $content to display content of layout A.

I tried this and was not able to get it to work



<?php $this->beginContent('/testview',array()) ;   ?>


  Start <?php echo "aa".$content;  ?> End


<?php $this->endContent();   ?>


no matter what I place between "beginContent" & "endContent" it always only shows the "testview".

Thoughts ?

NZ

Sorry got the view layer mixed up, the "testview" need the "echo $content" not the parent