Page design in help with a views

Hi Folks,

I am totaly newbie in Yii, so sorry for stupit question. I like MVC architecture, but could you please help me to answer question how to design page with more than one blocks of data?

You know, I have quite complex page where you can find for example chart, gainers boxes and other related content. I understand I will create one controller, more data models but what about views?

Is it in habbit to do one view per controller or it is better to have so many views I need there? For example each block on the page will have separate view?

Please help me to understand more to MVC, many thanks for your replies in advance!



Yes, a controller renders only one view file. But inside a view you can call renderPartial() to render another views (e.g. _form.php). Also you can use widgets, e.g. to display top news or lastest comments. But widgets usually go to a layout file and renderPartial is used inside a controller view file.

Thank you for your reply. I understand, but what is the best way to show more data outputs one one page? renderPartial or Widgets? Which one I should follow?


Use widgets to display same blocks for different controllers. Widgets are similar to controllers, they can also retrieve data from a database and pass it to their own views.