POST TIME:2017-12-15 22:52
織夢(DedeCMS)系統自定義字段圖片調用標簽:
一、實現方法1)創建自定義函數
打開 /include/extend.func.php 文件(注:這個文件就是系統預留的自定義函數接口文件,主要用于二次開發用的。如果你是老版本,默認沒有這個文件,自己創建一個PHP文件即可),在最下面的?>上一行加入以下函數代碼:
/**************** function GetOneImgUrl @@ 功能:讀取自定義字段圖片地址 *****************/
{dede:img text='' width='270' height='129'} /uploads/101017/1-10101H21F54P.gif {/dede:img} *****************/ 婚宴用了
function GetOneImgUrl($img,$ftype=1){ if($img <> ''){ $dtp = new DedeTagParse(); $dtp->LoadSource($img); if(is_array($dtp->CTags)){ foreach($dtp->CTags as $ctag){ if($ctag->GetName()=='img'){ $width = $ctag->GetAtt('width'); $height = $ctag->GetAtt('height'); $imgurl = trim($ctag->GetInnerText()); $img = ''; if($imgurl != '') { if($ftype==1){ $img .= $imgurl; } else{ $img .= "<img src='''.$imgurl.''' width='''.$width.''' height='''.$height.''' />"; } } } } } $dtp->Clear(); return $img; } } |