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 class="four columns">

		<?php echo $model->name; ?>



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


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:

I try with Clips, thanks!