render
render is used to display page with layout or theme.
$this->render('login',array('model'=>$model));
renderPartial
The renderPartial() method is also used for Ajax calls, where the layout isn’t appropriate
It will show content of particular view file only and will not include theme files like css, js, header, footer etc.[empty theme content view]
- When we make a ajax request where we have to show only page body, We will use the renderPartial
- To access the different controller view file, we will use the renderPartial.
Double Slash
<?php $this->renderPartial('//controller/view')?>
“//”- will render the view protected/views/controller/view.php
Single Slash
<?php $this->renderPartial('/controller/view')?>
“/”- will render the view from current module
Another Controller View
Using renderPartial() method we can call the view of another controller. We can reuse view files. we can call function in view and controller files.
<?php $this->renderPartial( 'application.views.user.index', array( 'data'=>'Welcome', 'model'=>$model, ));?>