首页 > 网站 > 建站经验 > 正文

ecshop 调用广告位函数分享

2024-04-25 20:34:40
字体:
来源:转载
供稿:网友

今天分享一下ecshop广告位调用的函数,是做项目的时候用到的,分享一下。

//广告位

//获取的广告数

function get_advlist($position, $num=0)

{

$arr=array();

$limit_string = '';

if ($num > 0)

{

$limit_string = 'limit '.$num;

}

$sql = "select ap.ad_width,ap.ad_height,ad.ad_id,ad.ad_name,ad.ad_code,ad.ad_link,ad.ad_id,ad.link_man 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 UNIX_TIMESTAMP()>ad.start_time and UNIX_TIMESTAMP()<ad.end_time and ad.enabled=1 $limit_string";

$res = $GLOBALS['db']->getAll($sql);

foreach($res as $idx => $row)

{

$arr[$row['ad_id']]['name'] = $row['ad_name'];

$arr[$row['ad_id']]['title'] = $row['link_man'];

$arr[$row['ad_id']]['url'] = "affiche.php?ad_id=".$row['ad_id']."&uri=".$row['ad_link'];

$arr[$row['ad_id']]['image'] = 'data/afficheimg/'.$row['ad_code'];

$arr[$row['ad_id']]['ad_code'] = $row['ad_code'];

$arr[$row['ad_id']]['content'] = "<a href='".$arr[$row['ad_id']]['url']."' title='".$row['ad_name']."' target='_blank'><img src='data/afficheimg/".$row['ad_code']."' title='".$row['ad_name']."' alt='".$row['ad_name']."' class='img-responsive'/></a>";

}

return $arr;

}

 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表