在進行頁面輸出渲染的時候。1.render 輸出父模板的內容,將渲染的內容,嵌入父模板。|
2.renderPartial 則不輸出父模板的內容。只對本次渲染的局部內容,進行輸出 " /> 成年人看的毛片,aaa a特级黄,精品一区二区三区免费毛片

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

Yii中render和renderPartial的區別

以下由我們在信易網絡公司開發項目的時候終結出的一些經驗
在進行頁面輸出渲染的時候。

1.render 輸出父模板的內容,將渲染的內容,嵌入父模板。|
2.renderPartial 則不輸出父模板的內容。只對本次渲染的局部內容,進行輸出。

同時還有個重要的區別:

render 函數內部默認執行processOutput($output)函數, 會將把組件,比如 CTreeView 里面注冊到 CClientScript 里面的
需要的腳本進行渲染輸出。

而renderPartial() 默認不自動渲染輸出客戶端腳本,需要進行參數的指定,才會輸出:
renderPartial($view,$data=null,$return=false,$processOutput=false)
指定processOutput 為 true 即可。

比如要局部輸出 CTreeView ,用renderPartial 進行渲染,如果按照默認processOutput=false 則輸出內容,不含有客戶端腳本
輸出內容則為 正常的 ul 列表。沒有樹形的折疊效果。 主動設定 processOutput=true 后,CTreeView 所需的,所有客戶端腳本就會被正常輸出在列表的前面。

下面介紹下要用到的幾個相關的函數:

render,renderPartial 不再介紹
processOutput()

<?phppublicfunction 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;  }}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 the requested view "{view}".',      array('{controller}'=>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;}

以上在實際操作中還是比較有用的,比如你不想用大組建,可以直接將變量輸到模板,也可以將多個變量組成數組輸到模版里面去.

php技術Yii中render和renderPartial的區別,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 明天属于我们法剧免费观看| 托宾贝尔| 同性gay在线| 猎魔人第一季| 孤战迷城 电视剧| 杨紫和肖战演的电视剧是什么| 《起风了》数字简谱| 视频一区二| 单招考试查询成绩入口| 徐正超| 韩国电影金珠| 三人越谷文言文翻译| dj视频mv| 日记| 松永| 奖励员工的表扬通告怎么写| 金发女郎| 头像图片2024最新款女| run on| 醉翁亭记理解性默写及答案| 黄网站在线免费看| 开运咒| 张天爱出生于哪年?| 风之谷钢琴谱| 色蝴蝶| 派拉蒙影业| 美女自愿戴镣铐调教室| 色在线看| 超人机梅塔路达| 东方电视台节目表今日节目| 入党培养考察情况范文| 林一个人简介资料| 妙探出差3| 高达w| 白洁教师| k总直播间| 魔法少女砂沙美| 陈瑞的情债| 电影《村小的孩子》完整版| 我记得你| 69视频污|