ECSHOP 首页分类广告调用

/* 首页各分类广告图片 例如:部署在include/libcommon.php */
function get_adv($position) 
{ 
	$sql = "select ap.ad_width,ap.ad_height,ad.ad_id,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 ap.position_name='".$position."' and ad.media_type=0 and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1 order by ad.ad_id desc limit 1"; 

	$res = $GLOBALS['db']->getRow($sql); 
	if($res) 
	{ 
		return  "<a href='affiche.php?ad_id=".$res['ad_id']."&uri=".$res['ad_link']."' target='_blank'><img src='data/afficheimg/".$res['ad_code']."' width='".$res['ad_width']."' height='".$res['ad_height']."' /></a>"; 
	} 
	else 
	{ 
		return ""; 
	} 
}

/*模板.dwt对应位置引用*/
 <div class="f_l"><?php $GLOBALS['smarty']->assign('index_cat_image', get_adv('首页-分类ID'.$GLOBALS['smarty']->_var['goods_cat']['id'].'-左边图片广告')); ?>{$index_cat_image}</div>

<div class="f_r"><?php $GLOBALS['smarty']->assign('index_cat_image', get_adv('首页-分类ID'.$GLOBALS['smarty']->_var['goods_cat']['id'].'-右边图片广告'));?> {$index_cat_image}</div>

你可能感兴趣的:(ecshop分类广告调用,ecshop广告)