您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程

ecshop首页轮播广告图片播放器怎么用js播放器替换

陈茗卓2023-11-30 21:18:44ecshop商城教程已有人查阅

导读1、首页主广告管理-》自定义,粘下以下代码;寻找$smarty->display('index.dwt', $cache_id);下面加:

1、首页主广告管理-》自定义,粘下以下代码:
<script type="text/javascript">
var glide =new function(){
function $id(id){return document.getElementByIdx_x(id);};
this.layerGlide=function(auto,oEventCont,oSlider,sSingleSize,second,fSpeed,point){
var oSubLi = $id(oEventCont).getElementsByTagName_r('li');
var interval,timeout,oslideRange;
var time=1;
var speed = fSpeed
var sum = oSubLi.length;
var a=0;
var delay=second * 2000;
var setValLeft=function(s){
 return function(){
oslideRange = Math.abs(parseInt($id(oSlider).style[point]));
$id(oSlider).style[point] =-Math.floor(oslideRange+(parseInt(s*sSingleSize) - oslideRange)*speed) +'px'; 
if(oslideRange==[(sSingleSize * s)]){
 clearInterval(interval);
 a=s;
}
 }
};
var setValRight=function(s){
 return function(){ 
oslideRange = Math.abs(parseInt($id(oSlider).style[point]));
$id(oSlider).style[point] =-Math.ceil(oslideRange+(parseInt(s*sSingleSize) - oslideRange)*speed) +'px';
if(oslideRange==[(sSingleSize * s)]){
 clearInterval(interval);
 a=s;
}
 }
}
function autoGlide(){
 for(var c=0;c<sum;c++){oSubLi[c].className='';};
 clearTimeout(interval);
 if(a==(parseInt(sum)-1)){
for(var c=0;c<sum;c++){oSubLi[c].className='';};
a=0;
oSubLi[a].className="active";
interval = setInterval(setValLeft(a),time);
timeout = setTimeout(autoGlide,delay);
 }else{
a++;
oSubLi[a].className="active";
interval = setInterval(setValRight(a),time);
timeout = setTimeout(autoGlide,delay);
 }
}
if(auto){timeout = setTimeout(autoGlide,delay);};
for(var i=0;i<sum;i++){
 oSubLi.onmouseover = (function(i){
return function(){
 for(var c=0;c<sum;c++){oSubLi[c].className='';};
 clearTimeout(timeout);
 clearInterval(interval);
 oSubLi.className="active";
 if(Math.abs(parseInt($id(oSlider).style[point]))>[(sSingleSize * i)]){
interval = setInterval(setValLeft(i),time);
this.onmouseout=function(){if(auto){timeout = setTimeout(autoGlide,delay);};};
 }else if(Math.abs(parseInt($id(oSlider).style[point]))<[(sSingleSize * i)]){
 interval = setInterval(setValRight(i),time);
this.onmouseout=function(){if(auto){timeout = setTimeout(autoGlide,delay);};};
 }
}
 })(i) 
}
}
}
glide.layerGlide(true,'icon_num','show_pic',534,2,0.1,'left');
</script>
<!-- 向右效果 -->
2、index.php:
寻找$smarty->display('index.dwt', $cache_id);下面加:
function get_flash_xml()
{
$flashdb = array();
if (file_exists(ROOT_PATH . DATA_DIR . '/flash_data.xml'))
{
 // 兼容v2.7.0及以前版本
if (!preg_match_all('/item_url="([^"]+)"\slink="([^"]+)"\stext="([^"]*)"\ssort="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER))
{
preg_match_all('/item_url="([^"]+)"\slink="([^"]+)"\stext="([^"]*)"/', file_get_contents(ROOT_PATH . DATA_DIR . '/flash_data.xml'), $t, PREG_SET_ORDER);
}
if (!empty($t))
{
foreach ($t as $key => $val)
{
$val[4] = isset($val[4]) ? $val[4] : 0;
$flashdb[] = array('src'=>$val[1],'url'=>$val[2],'text'=>$val[3],'sort'=>$val[4]);
}
}
}
return $flashdb;
}
3、寻找
$smarty->assign('auction_list',index_get_auction());// 拍卖活动,下面加上:
$smarty->assign('playerdb', get_flash_xml()); // FLASHJS广告
4、index_ad.lbi:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- {if $index_ad eq 'sys'} -->
<script type="text/javascript">
var swf_width=534;
var swf_height=200;
</script>
<script type="text/javascript" src="data/flashdata/{$flash_theme}/cycle_image.js"></script>
<!-- {elseif $index_ad eq 'cus'} -->
<!-- {if $ad.ad_type eq 0} -->
<a href="{$ad.url}" target="_blank"><img src="{$ad.content}" width="534" height="200" border="0"></a>
<!-- {elseif $ad.ad_type eq 1} -->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="534" height="200">
<param name="movie" value="{$ad.content}" />
<param name="quality" value="high" />
<embed src="{$ad.content}" quality="high" pluginspage="http://www.ebingou.cn/go/getflashplayer" type="application/x-shockwave-flash" width="534" height="200"></embed>
</object>
<!-- {elseif $ad.ad_type eq 2} -->
<div id="picBox">
<ul id="show_pic" style="left:0;">
{foreach from=$playerdb item=item key=key}
<li><a href="{$item.url}" target="_blank"><img src="{$item.src}" alt="{$item.text}" /></a></li>
{/foreach}
</ul>
<ul id="icon_num">
{foreach from=$playerdb item=item name=picsitem key=key}
<li <!--{if $smarty.foreach.picsitem.iteration eq 1}-->class="active" <!--{/if}-->>{$item.text}</li>
{/foreach}
</ul>
</div>
{$ad.content}
<!-- {elseif $ad.ad_type eq 3} -->
<a href="{$ad.url}" target="_blank">{$ad.content}</a>
<!-- {/if} -->
<!-- {else} -->
<!-- {/if} -->
5、CSS文件
#picBox{width:534px; height:232px; overflow:hidden; position:relative; z-index:999;border:1px solid #0000ff}
#picBox ul#show_pic{height:202px; width:3050px; position:absolute;}
#picBox ul#show_pic li{ float:left; height:202px;}
#picBox ul#show_pic li img{ display:block; width:534px;height:200px}
#icon_num{ position:absolute; bottom:0px; left:0px;width:534px; overflow:hidden;}
#icon_num li { float:left;background:#565662; font-weight:bold;color:#fff; display:block;cursor:pointer;width:135px;padding:5px;text-align:center; border-right:1px solid #fff; font-size:13px;}
#icon_num li:hover,#icon_num li.active{ background:#000000; color: red;}

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

本栏推荐

相关标签