ecshop其他页面广告轮播实现方法
利用后台的广告位置 广告列表功能:
先添加一个广告位置 查看它的id
//取的其他页面flash轮播
function getflashbanner($id)
{
$sql = "select * from ".$GLOBALS['ecs']->table('ad')." where position_id='$id'";
$res = $GLOBALS['db']->getAll($sql);
$img = '';
$link = '';
$num = count($res);
foreach($res as $idx=>$value)
{
if($idx!=$num-1)
{
$line = '|';
}
else
{
$line ='';
}
$img .= 'data/afficheimg/'.$value['ad_code'].$line;
$link .= $value['ad_link'].$line;
}
$banner = array();
$banner['img'] = $img;
$banner['link'] = $link;
return $banner;
}
function getflashbanner($id)
{
$sql = "select * from ".$GLOBALS['ecs']->table('ad')." where position_id='$id'";
$res = $GLOBALS['db']->getAll($sql);
$img = '';
$link = '';
$num = count($res);
foreach($res as $idx=>$value)
{
if($idx!=$num-1)
{
$line = '|';
}
else
{
$line ='';
}
$img .= 'data/afficheimg/'.$value['ad_code'].$line;
$link .= $value['ad_link'].$line;
}
$banner = array();
$banner['img'] = $img;
$banner['link'] = $link;
return $banner;
}
复制此函数到需要的php文件 或者include下的共同文件里
$smarty->assign('flashbanner_bgyp',getflashbanner(3)); 对应php文件的调用
<script type="text/javascript">
var swf_width=730
var swf_height=107
var files ='{$flashbanner_bgyp.img}';
var links = '{$flashbanner_bgyp.link}';
var texts = '';
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="focusok.swf"><param name="quality" value="high">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'">');
document.write('<embed src="focusok.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
</script>
//对应模板的显示
需要把一个js文件放根目录 。在附件
赞 (0)