织梦获取本栏目图片,判断本栏目没有图片只时候才返回顶级图片
如何实现织梦获取本栏目图片,只有找不到时候才返回顶级图片,打开织梦include/extend.func.php里最底部加上函数:
/* * 获取本栏目图片,只有找不到时候才返回顶级图片 * $typeid 栏目id * $default_pic 找不到时候默认图片 * [field:field:id function='get_channelchannel_pic(@me)'/] * */function get_channel_pic($typeid,$default_pic="/images/defaultpic.gif"){ global $dsql; $row = $dsql->GetOne("SELECT arcpic,topid FROM dede_arctype WHERE id= $typeid");if(empty($row['arcpic'])){ if(0 == $row['topid']){ return $default_pic; }else{ $row1 = $dsql->GetOne("SELECT arcpic FROM dede_arctype WHERE id= $row[topid]"); return (empty($row1['arcpic']))?$default_pic:$row1['arcpic']; } }else{ return $row['arcpic']; } }