[solved] Layout with partials

Hi, I have a situation i cannot solve with Yii Framework.

I know how to do it in Ruby on Rails, Joomla etc.

I have several controller in a web site with the same layout.

In the top i have several part the are equal but are loaded from database.

Exemple, main menu loaded from DB.

In every controller i have to call the same method and in the last, load the content from the actual page.

How can i solve this?

Should I call the model method inside the layout? (main.php)

Please, guide me and I will learn.

and… almost forgot.

Yiii is lovely!

If I understand you correctly, you may create a widget to deal with this (see MainMenu included in the yiic webapp as an example). You may put your DB accessing logic in the class.

You may also consider write a base controller which would serve the common content for the layout. And then all your other controllers extend from this base class. In the layout, you can call $this->xyz() to do the job you want.

You undertood me correctly.

I have used your second suggestion in ruby on rails and zend framework application in my last application.

I don't know very well the concept of widget but as I understood it will solve the problem. I see the example.

The mini-code worth this solution.

Your 2 options were wise.