Here are some of the lessons we've ended when we developed a project in the Trust Network company.
At the time of rendering the page output.
1.render outputs the contents of the parent template, renders the rendered content, and embeds the parent template. |
2.renderPartial does not output the contents of the parent template. Output only for the local content of this rendering.
And there's one important difference:
The render function internally defaults to the Processoutput ($output) function, which registers the component, such as CTreeView, inside the Cclientscript
The required script to render the output.
The renderpartial () does not automatically render the output client script by default, and the parameter needs to be specified before it is output:
RenderPartial ($view, $data =null, $return =false, $processOutput =false)
Specifies that Processoutput is true.
For example, to local output CTreeView, rendering with renderpartial, if you follow the default Processoutput=false output content, does not contain client script
The output is a normal list of UL. There is no tree-shaped folding effect. Once the processoutput=true is active, all client script will be output normally in front of the list, CTreeView required.
Here are a few of the related functions to use:
Render,renderpartial no longer introduce
Processoutput ()
<?php publicfunction Render ($view, $data =null, $return =false) {if ($this->beforerender ($view)) {$output = $thi
S->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; } publicfunction 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 Thrownewcexception (yii::t (' Yii ', ' {controller} cannot find ' requested view ' {view} '. ', Array (' {contro
Ller} ' =>get_class ($this), ' {view} ' => $view)); } publicfunCtion Processoutput ($output) {Yii::app ()->getclientscript ()->render ($output); If using page caching, we should delay dynamic output replacement if ($this->_dynamicoutput!==null&& $this-
>iscachingstackempty ()) {$output = $this->processdynamicoutput ($output);
$this->_dynamicoutput=null;
if ($this->_pagestates===null) $this->_pagestates= $this->loadpagestates ();
if (!empty ($this->_pagestates)) $this->savepagestates ($this->_pagestates, $output);
return $output; }
The above in the actual operation is more useful, for example, you do not want to use a large build, you can directly to the template, you can also make a number of variables to form an array to die version inside.