参考文档
应用的场景: 页面的某一部分多次被使用
最简单的一种应用 ,但是这种写法是被弃了,大佬选择了写一个php文件,require 加载的模式
挂件的写法
useyiibaseWidget;
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]);?>