Home >Backend Development >PHP Tutorial >PHP development framework Yii Framework tutorial (12) UI component ClipWidget example

PHP development framework Yii Framework tutorial (12) UI component ClipWidget example

黄舟
黄舟Original
2017-01-21 10:10:241382browse

CClipWidget provides a function similar to recording "macro". The content defined between init and run of CClipWidget can be stored in the Clip variable of Controller, and then played back to any other location.

CClipWidget encapsulates CBaseController's beginClip and endClip. The basic usage of CBaseController's beginClip and endClip is as follows:

First define Clip

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

and then use this Clip where needed.

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

If $this points not to the Controller, but to a Widget, you can use

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

The method of using ClipWidget is as follows,

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

First Clip is also defined, which is defined through beginWidget and endWidget. The ID of the clip is passed in by the parameter id. Then you can call echo $this->clips['record']; to display the recorded content where needed. The content between beginWidget and endWidget can be customized as needed. In this example, three lines of text are displayed.

The displayed results are as follows:

PHP development framework Yii Framework tutorial (12) UI component ClipWidget example

The above is the content of the PHP development framework Yii Framework tutorial (12) UI component ClipWidget example. For more related content, please pay attention to PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn