module/application nested layouts

How to use a module’s layout within the application layout?

If I have:


<div>

this is views/layouts/main.php

<?php echo $content; ?>

</div>

Then when ?r=mymodule/foo/bar is called, the above $content should get the output generated by the mymodule layout:


<div>

this is modules/mymodule/views/layouts/main.php

<?php echo $content; ?>

</div>

where the above $content gets it value from modules/mymodule/views/foo/bar.php with the help of FooController::actionBar().

So note, nesting is wanted, not overwriting the global (application’s) layout.

Say the modules/mymodule/controllers/FooController::actionBar() action generates the output "Hello world", the entire output should look like this:


<div>

this is views/layouts/main.php

<div>

this is modules/mymodule/views/layouts/main.php

Hello world

</div>

</div>

Found it, though not elegant and possibly buggy. I’ll come back with the code for RFCs when I’ll feel the code is stable enough.