DedeCMS有很多标签调用时自带了HTML代码,其实留给自己处理更好更灵活。比如自定义字段为图片时(字段名:name),输出的格式有时候并不是我们想要的,内容页用{dede:field.name/}
{dede:img text='' width='270' height='129'}/uploads/101017/1-10101H21F54P.gif{/dede:img}
前台输出格式如下:
创建自定义函数
打开/include/extend.func. php,在最下面复制以下代码(?>前面)
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 .= '';
}
}
}
}
}
$dtp->Clear();
return $img;
}
}
前台内容页格式为:
@me,0 代表只输出路径
@me,1 代表连宽、高一起输出
同样的列表页或首页用相应的标签套进去就行了。
扩展阅读
本文地址:https://www.vi586.com/web/211.html
版权声明:原创文章,版权归重庆SEO吖七所有,欢迎分享本文,支持原创,转载请保留出处