© 2002-2018  最模板 zuimoban.com 版权所有,并保留所有权利。
   ecshop模板网,专注ecshop模板制作、ecshop二次开发服务!
     
 文章详情以首页为例,调用不同的 分类,显示不同的广告:
includes/init.php ?>前 增加如下代码:
	
| 
					 
							1
						 
						
							2
						 
						
							3
						 
						
							4
						 
						
							5
						 
						
							6
						 
						
							7
						 
						
							8
						 
						
							9
						 
						
							10
						 
						
							11
						 
						
							12
						 
						
							13
						 
						
							14
						 
						
							15
						 
						
							16
						 
						
							17
						 
						
							18
						 
						
							19
						 
						
							20
						 
						
							21
						 
						
							22
						 
						
							23
						 
						
							24
						 
						
							25
						 
						
							26
						 
						
							27
						 
						
							28
						 
					 | 
				
					 
							function get_uuecs_adv($type,$id)
						 
						
							{
						 
						
							     $sql = "sel ect ap.ad_width,ap.ad_height,ad.ad_name,ad.ad_code,ad.ad_link,ad.media_type 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 OR ad.media_type=3) and UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1";
						 
						
							     $row = $GLOBALS['db']->getRow($sql);
						 
						
							     if($row)       
						 
						
							     {      
						 
						
							         if($row['media_type'] == 0)
						 
						
							        {       
						 
						
							            $src = (strpos($row['ad_code'], 'http://') === false && strpos($row['ad_code'], 'https://') === false) ?
						 
						
							                        DATA_DIR . "/afficheimg/$row[ad_code]" : $row['ad_code'];
						 
						
							            return "<a href='affiche.php?ad_id=$row[ad_id]&uri=" .urlencode($row["ad_link"]). "'
						 
						
							                target='_blank'><img src='$src' width='" .$row['ad_width']. "' height='$row[ad_height]'
						 
						
							                border='0' /></a>";    
						 
						
							        }
						 
						
							        else
						 
						
							        {
						 
						
							               return "<a href='affiche.php?ad_id=$row[ad_id]&uri=" .urlencode($row["ad_link"]). "'
						 
						
							                target='_blank'>" .htmlspecialchars($row['ad_code']). '</a>';
						 
						
							        }
						 
						
							     }
						 
						
							     else
						 
						
							     {
						 
						
							        return "";
						 
						
							     }  
						 
						
							}
						 
					 | 
			
2) includes/lib_goods.php (即调用分类商品函数)
搜索$cat['id'] = $cat_id;下面增加:
$cat['ad'] = get_uuecs_adv('index_1',$cat_id);
3)在模板文件添加代码即可:如library/cat_goods.lbi
增加代码{$goods_cat.ad}即可。
4)对了,别忘了在后台添加广告哦。
切记:广告名称个固定格式:index_1_18,这样分类ID为18的分类下面才会显示出该广告来。