oligalma
(Marc Oliveras)
1
Hi, I’d like to render the main.php layout of another module. For example:
[b]
column1.php[/b]
<?php $this->beginContent('//modules/blog/views/layouts/main'); ?>
<div id="content">
<?php echo $content; ?>
</div>
<?php $this->endContent(); ?>
Is that possible?
I would suggest to solve this using themes
and then you can specify your own layouts for modules in a theme.
To get you an idea…
Suppose you have modules module1 and module2 and you create themes theme1 and theme2
then you would need these layouts:
themes/theme1/views/module1/layouts/main.php
themes/theme1/views/module2/layouts/main.php
themes/theme2/views/module1/layouts/main.php
themes/theme2/views/module2/layouts/main.php
You can change the theme on the fly either in a module or in a controller.
class Module1Module extends CWebModule {
public function init() {
$this->setImport(array(
'module1.models.*',
'module1.components.*',
));
Yii::app()->theme = 'theme1';
}
}
class DefaultController extends Controller {
public function actionIndex() {
Yii::app()->theme = 'theme1';
$this->render('index');
}
}