日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

yiilite.php,YII Framework学习教程-YII的V-view的render若干函数-2011-11-17 | 学步园

發布時間:2024/9/27 php 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 yiilite.php,YII Framework学习教程-YII的V-view的render若干函数-2011-11-17 | 学步园 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

YII中,在action可以通過$this->render來指定它的view。其實還其他一$this->render開頭的函數。

yiilite.php中有這么幾個函數。

public function renderText($text,$return=false)

{

if(($layoutFile=$this->getLayoutFile($this->layout))!==false)

$text=$this->renderFile($layoutFile,array('content'=>$text),true);

$text=$this->processOutput($text);

if($return)

return $text;

else

echo $text;

}

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)));

}

public function renderClip($name,$params=array(),$return=false)

{

$text=isset($this->clips[$name]) ? strtr($this->clips[$name], $params) : '';

if($return)

return $text;

else

echo $text;

}

public function renderDynamic($callback)

{

$n=count($this->_dynamicOutput);

echo "";

$params=func_get_args();

array_shift($params);

$this->renderDynamicInternal($callback,$params);

}

public function renderDynamicInternal($callback,$params)

{

$this->recordCachingAction('','renderDynamicInternal',array($callback,$params));

if(is_string($callback) && method_exists($this,$callback))

$callback=array($this,$callback);

$this->_dynamicOutput[]=call_user_func_array($callback,$params);

}

例如讓action只輸出一句話,不應用layout。可以用renderText

/**

* This is the default 'index' action that is invoked

* when an action is not explicitly requested by users.

*/

public function actionIndex()

{

//$viewData=array();

// renders the view file 'protected/views/site/index.php'

// using the default layout 'protected/views/layouts/main.php'

//$viewData['homeUrl'] = Yii::app()->homeUrl;

//$viewData['var1'] = '這是var1變量的對應的值';

//$this->layout='mylayout';

//$this->renderPartial('index',$viewData);

$this->layout=false;

$this->renderText('test',$return=false);

}

看看上面的render原型,可以看到可以調用一個回調函數。具體功能可以自己代碼試用一下。

更強大的功能,需要自己慢慢發現。

總結

以上是生活随笔為你收集整理的yiilite.php,YII Framework学习教程-YII的V-view的render若干函数-2011-11-17 | 学步园的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。