Dinamic content in layout

Hi all,

Layout is:

"… a special view that is used to decorate views. It usually contains portions of user interface that are common among several views."

What if a have a widget (slideshow) that receives an array of data to display in a …slideshow =P,

If depending on the view. I need to generate this data from diferent models. say when in the article show view I want the slideshow to display other articles but when in the videos show view I want the slideshow to display other videos…

How should i handle this logic in a good way?, The slideshow for sure should belong to the layout, as it is exactly the same for both views. but where should I put the logic of generating the array that ill pass to it?

I cant put that into the widget as it would then be attached to my models. I want my widgets to receive a generical array of data not carring if it belongs to a model or not. as it sounds because it depends on the model then the controller should have that logic… but… I cant send information to the layout from a controller. so…

what would be your sugestion?

You can put a public method like getSlideshowData() into your controller that provides the required data. If you have different controllers for article and videos you can then decide which data to provide. As default you could put the same method into your base controller that returns e.g. null and in your widget display nothing if data===null. In the layout you fetch that data with $this->getSlideshowData().

Works worderfull thanks! =D didnt figure that $this refers to the controller even in the layout.