Using base controller and passing data to view

Hello there,

I’m using the base controller (components/controller.php) that I extend all my controllers from. I want to put some logic in there that is executed on all the controllers but is passed down to the view. Now the only way I know how to pass something to the view is with $this->render method, which won’t work, because it would be double rendering at times.

Any ideas? I just want to pass something to the view or have it accesible by the view without rendering.

Thanks

On second thought, why do I even bother to open these threads because I have an answer I find for myself that works within the first 30 minutes… lol

What I did was made a public property at the top named list, then accessed the property via the view :)

controller:




public $list = array();


...

$this->list = array('item1','item2','item3');

...



view:




print_r($this->list);



Hope that helps somebody :)

Hi jwerd!

this thread is worthwhile ! http://www.yiiframework.com/forum/index.php?/topic/4473-how-to-pass-variable-to-a-layout/