renderPartial

Hi,

I have been having a look at the renderPartial method. Where is this method suppose to go? In my controller or in my view file.

If its in the view file then how do I use it?

$renderPartial renders a view without layouts , i prefer use it on ajax calls

Ahh I see, so it different from the renderPartial in Rails.

I assume I am suppose to do a …

renderPartial header

renderPartial middle

renderPartial footer

In the controller then, kind of like CodeIgniter.

In Rails renderPartials where used in the view files, and where more like "include" statement in PHP.

You can use renderContent(‘the_content’) in views.

If that’s what you’re asking.

You can also use renderPartial which is like including a view in a view.

renderContent is wrapping the wrapped content in a layout:


<?php $this->beginContent('//layouts/main'); ?>

//content to be wrapped in layouts/main through content variable

<?php $this->endContent(); ?>



RenderPartial:


<?php $this->pageTitle = 'Update ' . $model->title . ' - ' . $this->pageTitle; ?>

<h3>Update <i><?php echo CHtml::encode($model->title); ?></i></h3>

<?php echo $this->renderPartial('_form', array('model'=>$model)); ?>

I actually use renderContent to wrap my email messages in the email layout (different from my main layout).

If that’s not what you’re asking, ask again.

renderPartial is used to call view file from controller

Like render it is called to create html from view files.

Unlike render it does not use layouts and published js and css via CClientScript.