Yii widgets 这个东西很有意思,但项目里很多人都不用,简单介绍下用法 例子: 在‘protected\components’目录下新建 UserDown.php widgets代码如下
<?php //创建widgets例子 Yii::import('zii.widgets.CPortlet'); class UserDown extends CPortlet { public function init() { //$this->title=CHtml::encode(Yii::app()->user->name); parent::init(); } protected function renderContent() { $downLogUrl = Yii::app()->baseUrl.'./api/down_log.txt'; $downCount = (int)file_get_contents($downLogUrl,true); $this->render('userDown',array( 'downCount' => $downCount )); } } //调用方法 <?php $this->widget('UserDown'); ?>
查看更多关于PHP Yii Widgets添加方式的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did8507