Can I Send Variables To Layout Columns?

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!

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!