ecshop的分類廣告,因為分類很多,不可能所有分類用同一個廣告,那么我們設置廣告通過分類的ID判斷,但是ecshop默認沒有提供這些功能,最模板提供方法:
首先增加函數:
function get_adv($type,$id)
{
$sql = "select ap.ad_width,ap.ad_height,ad.ad_name,ad.ad_code,ad.ad_link from ".$GLOBALS['ecs']->table('ad_position')." as ap left join ".$GLOBALS['ecs']->table('ad')." as ad on ad.position_id = ap.position_id where ad.ad_name='".$type."_".$id."' and ad.media_type=0 and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1";
$res = $GLOBALS['db']->getRow($sql);
if($res)
return "<a href='".$res['ad_link']."' target='_blank'><img src='zuimoban/afficheimg/".$res['ad_code']."' width='".$res['ad_width']."' height='".$res['ad_height']."' /></a>";
else
{
return "";
}
}
若是在首頁分類下調用,代碼就是 <?php echo get_adv('zuimoban_y',$GLOBALS['smarty']->_var['goods_cat']['id'])?>
若是在分類頻道下調用,代碼就是<?php echo get_adv('zuimoban_d',$GLOBALS['smarty']->_var['category'])?>
后臺廣告位是cat_y_id
新聞熱點
疑難解答