Yii Framework Forum: Usage Of Echo In Renderpartial() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Usage Of Echo In Renderpartial() Rate Topic: -----

#1 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 258
  • Joined: 15-August 12

Posted 21 March 2013 - 03:29 AM

I saw in Yii Blog example for renderPartial() had used this code:

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

why did used from echo in the beginning of code?

I know what's third parameter of renderPartial(). when we don't want to use boolean $return=true what's the need to use echo?

public string renderPartial(string $view, array $data=NULL, boolean $return=false, boolean $processOutput=false)
0

#2 User is offline   lagogz 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 454
  • Joined: 30-November 12
  • Location:Galiza

Posted 21 March 2013 - 05:52 AM

Good morning.

I think renderPartial() translates the view code to HTML and it returns a string with this code.

Then, we need to do an echo to print it.

renderPartial()

Regards.
-----------------------------------------------------------------------------------------------
------------------------------- VISITEN FOCUCHASART --------------------------------
-----------------------------------------------------------------------------------------------
0

#3 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 21 March 2013 - 06:37 AM

View Postlagogz, on 21 March 2013 - 05:52 AM, said:

Good morning.

I think renderPartial() translates the view code to HTML and it returns a string with this code.

Then, we need to do an echo to print it.

renderPartial()

Regards.

No You dont need to echo there. In this case it's not needed.
But You can use it like
<?php echo $this->renderPartial('_form', array('model'=>$model),true); ?>
in this case u need echo.
function explains it better:
public function renderPartial($view,$data=null,$return=false,$processOutput=false)
{
if(($viewFile=$this->getViewFile($view))!==false)
{
$output=$this->renderFile($viewFile,$data,true);
if($processOutput)
$output=$this->processOutput($output);
if($return)
return $output;
else
echo $output;
}
else
throw new CException(Yii::t('yii','{controller} cannot find the requested view "{view}".',
array('{controller}'=>get_class($this), '{view}'=>$view)));
}

0

#4 User is offline   msoa 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 258
  • Joined: 15-August 12

Posted 21 March 2013 - 07:19 AM

View Postmirunho, on 21 March 2013 - 06:37 AM, said:

No You dont need to echo there. In this case it's not needed.
But You can use it like
<?php echo $this->renderPartial('_form', array('model'=>$model),true); ?>
in this case u need echo.

I described in first post your order, when we need go to use echo that the third parameter set to true.
My talk is, why in Yii blog example there is this mistake?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users