Answer the question
In order to leave comments, you need to log in
Which method generates html output in yii2?
There is a need to process all the source code before giving it to the browser.
in yii1 i just inherited the render() method of the CController class
<?php
class Controller extends CController
{
public function render($view,$data=null,$return=false){
if($this->beforeRender($view)){
$output=$this->renderPartial($view,$data,true);
if(($layoutFile=$this->getLayoutFile($this->layout))!==false){
$output=$this->renderFile($layoutFile,array('content'=>$output),true);
}
$this->afterRender($view,$output);
$output=$this->processOutput($output);
}
if($return)
return $output;
else
echo $output;
}
}
}
Answer the question
In order to leave comments, you need to log in
The controller delegates view rendering to the view itself . Actually it is engaged in the formation of content.
But in general, overriding the render method is not a good practice. If you need to do something with the content, it is better to use for this event or response formatting
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question