成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

render與renderPartial在Yii中有什么不同-創(chuàng)新互聯(lián)

本篇文章為大家展示了render與renderPartial在Yii中有什么不同,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。

我們提供的服務(wù)有:成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、天臺ssl等。為上千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的天臺網(wǎng)站制作公司

在進(jìn)行頁面輸出渲染的時(shí)候。

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

同時(shí)還有個(gè)重要的區(qū)別:

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

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

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

下面介紹下要用到的幾個(gè)相關(guān)的函數(shù):

render,renderPartial 不再介紹
processOutput()

<?php
publicfunction 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;
}

以上在實(shí)際操作中還是比較有用的,比如你不想用大組建,可以直接將變量輸?shù)侥0?也可以將多個(gè)變量組成數(shù)組輸?shù)侥0胬锩嫒?

上述內(nèi)容就是render與renderPartial在Yii中有什么不同,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

當(dāng)前文章:render與renderPartial在Yii中有什么不同-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://jinyejixie.com/article32/dicpsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、軟件開發(fā)、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站收錄、App設(shè)計(jì)企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)
黔南| 马公市| 神木县| 久治县| 电白县| 杭锦后旗| 沙洋县| 民勤县| 峨边| 桑日县| 宜良县| 北海市| 利辛县| 海盐县| 乐东| 尼木县| 泗阳县| 佛教| 林州市| 莎车县| 北碚区| 津南区| 洪湖市| 潼南县| 玉门市| 龙胜| 静乐县| 南城县| 泗水县| 江永县| 西林县| 开阳县| 冕宁县| 宝兴县| 竹山县| 丹阳市| 昌图县| 金昌市| 洛川县| 新乡市| 迁西县|