Yii框架的挂件的使用
2017-05-31 18:16
162 查看
参考文档
应用的场景: 页面的某一部分多次被使用
最简单的一种应用 ,但是这种写法是被弃了 ,大佬选择了写一个php文件,require 加载的模式
挂件的写法
页面的写法
应用的场景: 页面的某一部分多次被使用
最简单的一种应用 ,但是这种写法是被弃了 ,大佬选择了写一个php文件,require 加载的模式
挂件的写法
useyii\base\Widget; class ReportTagController extends Widget { public $tags;//循环的数据源 public $phas;//金融标签是不是要带上 p标签呢 0 不带 1带 public $host; public function init() { parent::init(); } public function run() { parent::run(); if ($this->phas) { $html = $this->getHtmlWithNoImg(); } else { $html = $this->getHtmlWithImg(); }
return $html;
} }
页面的写法
<?= ReportTagController::widget(['tags'=>$tel_info,'phas'=>0,'host'=>$host]);?>
相关文章推荐
- Yii框架使用总结
- Windows 环境下Yii框架的使用
- Yii框架使用
- PHP Yii框架中使用smarty模板
- Yii框架中CGridView的使用方法以及详细示例
- YII框架使用入门到精通
- 关于使用Yii框架开发时数据库增加字段后保存无效的问题
- 二:使用yii框架建立应用(数据库CURD基本操作)
- 一:使用yii框架win下面安装使用
- Yii框架 Cookie的使用方法详解
- PHP Yii框架中使用Jquery自带的Ajax功能
- YII框架yiic、gii工具使用方法
- YII框架yiic、gii工具使用方法
- 学习 yii 框架 – 使用简单的动作过滤器
- Yii框架中ActiveRecord使用Relations
- 初次使用YII框架时,安装过程中出现的问题
- 在zend studio中使用yii框架
- Yii框架中使用SRBAC作为权限管理模块时遇到的问题
- 使用Yii框架CHtml助手生成城市下拉选择框
- 使用yii框架开发第一步:配置yii框架环境和bootstrap扩展,使用代码生成器。