components layouts

Hi,

I have been reading the guide and i dont like layouts as views, i would see more logic and symmetric than the layouts were not views but components.

The rendering would be some type of chain of components, and in my layout component i could use the view that i want and with more control.

So i would like to set a component like a layout.

Qiang, ¿how could i do that?

Thx.

Maybe you can use some pseudo code to show how you would use your proposed component-based layouts?

class MyLayout extends CLayout

{

        private function getOtherData($data)

        {

        }

        protected function renderLayout($data)

        {

                $center = $data['center'];

                $myLayoutData = array(

                    'center'=>$center,

                    'otherdata'=>$this->getOtherData();

                )

                $this->render('mylayout',$myLayoutData);

        }

}

If i set the layout to a Clayout type, then the framework call my layout so

->layout->renderLayout(array('center'=>$center))

passing it the 'center' or perhaps more data than only the center.

And so i can set my own chain of layouts one that call the child or like

i want, i think this solution is a superset of the simple view layouts.

Thx.

How would the framework know it should pass 'center'?

I think your approach is similar to that implemented in Zend Framework where a view is represented in terms of an object. It is theoretically sounding and has some benefits. Practically, it is a bit troublesome to use. It also loses the benefit that inside of the view script file, you cannot use access the controller instance using $this. Any theming becomes more tricky.

I dont use zend (i hate it), and i didnt use yii yet(do you like my logo proposal?, hehe).

Well, when i say center, i refer to the result of the last controller rendering.

In my webs i dont use controllers, only components, because the controller is only a component more in my render tree chain.

I dont know if its a better solution for theming or so, i would know if there is a simple solution to continue using my own method but now inside yii that gives me a lot of things more.

I would not like to sell my soul and start using simple layouts, i see it like a step backward.

I would investigate this days the yii more deeper.

Thx Qiang.