kitune
(Shinkitune)
November 29, 2012, 10:16am
1
Hi! I’m using layouts in yii but I have a doubt. I can send a variable from controller to view via render().
And for example:
echo $model->name;
works fine.
But if I put this in column2.php for showing the name of the model in the sidebar for example, I can’t.
Any solution?
<?php $this->beginContent('//layouts/main'); ?>
<div class="row">
<div class="eight columns">
<?php echo $content; ?>
</div>
<div class="four columns">
<?php echo $model->name; ?>
</div>
</div>
<?php $this->endContent(); ?>
thanks!
redguy
(Maciej Lizewski)
November 29, 2012, 10:36am
2
you must extend controller (probably base controller class: protected/components/Controller.php), add there public attribute and then you can set its value in view file or action code and read in layout files with simple:
echo $this->attributeName;
another approach is to use clips: http://www.yiiframework.com/wiki/127/dynamic-sidebar-using-cclipwidget/
kitune
(Shinkitune)
November 29, 2012, 11:29am
3
redguy:
you must extend controller (probably base controller class: protected/components/Controller.php), add there public attribute and then you can set its value in view file or action code and read in layout files with simple:
echo $this->attributeName;
another approach is to use clips: http://www.yiiframework.com/wiki/127/dynamic-sidebar-using-cclipwidget/
I try with Clips, thanks!