PHP開發架構Yii Framework教程(12) UI 組件 ClipWidget樣本

來源:互聯網
上載者:User
CClipWidget提供了類似錄製“宏”的功能,定義在CClipWidget的init和run之間的內容可以存放在Controller的Clip變數中 ,然後重新回放到任意其它位置。

CClipWidget封裝的是CBaseController的beginClip和 endClip,CBaseController的 beginClip和 endClip的基本用法如下:

首先定義Clip

$this->beginClip('clipID');// ... display the clip contents$this->endClip();

然後再需要使用這個Clip的地方

echo $this->clips['clipID'];

如 果$this 指向的不是Controller,而是某個Widget,可以使用

echo $this->getController()->clips ['clipID'];

使用ClipWidget 的方法如下,

beginWidget('CClipWidget',array('id'=>'record')); ?>endWidget(); ?>clips['record']; ?>-----------clips['record']; ?>

首先也是定義Clip,這是通過beginWidget 和 endWidget 來定義,clip 的ID由參數id 傳入。然後就可以調用echo $this->clips['record']; 在需要的地方顯示這段錄製的內容。beginWidget 和 endWidget之間的內容可以根據需要自訂,本例顯示三行文字。

顯示結果如下:

以上就是PHP開發架構Yii Framework教程(12) UI 組件 ClipWidget樣本的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.