Rendering View inside View

Hello, I am pretty noob in Yii framework, but what I have found out is that it is a wonderful and powerful tool. So now I want to make separate "sections" in my view, and that combine then within the view, for examle:

I want to create a "register.php", "user_details.php", "left-navigation.php" … and then load them in a view, like so: home.php (the index page view) should load user-details.php and left-navigation.php … Do you understand what I want? so what are there a good ways of doing it? should i do it with view files or do it with widgets?

please, if you know best techniques for doing this, inform me.

Sorry for my English.

you can you renderParitial for this purpose like so:


$this->renderPartial('user-details');

put this in your main view file and it will render the contents of user-details.php.

Hope this helps

Yes! And remember that inside a view you are in a specific controller and action. This means that if your path is

/index.php?r=site/index

The controller is /protected/controllers/SiteController.php

The view is /protected/views/site/index

But … what if you want to show a view in anther folder like …

/protected/views/products/detail.php

Easy: you must specify the entire path:

$this->renderPartial(’//product/detail’);

Thank you very much for reply, but does it mean that I can use renderPartial method so many times as I want in a single view? Or is there some limits?

You can do renderPartial as much as you want.

PS: Make sure you do not end up in a loop :)