ecshop的首页主广告轮播替换为js翻转效果方法二
时间:2024年01月31日
/来源:网络
/编辑:佚名
找到ecshop 程序,打开模板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=725;
var swf_height=300;
</script>
<script type="text/javascript" src="data/flashdata/{$flash_theme}/cycle_image.js"></script>
<!-- {elseif $index_ad eq 'cus'} -->
<?php
if(!function_exists("get_ads")){
function get_ads($num)
{
$sql = 'select * from '.$GLOBALS['ecs']->table('ad_custom').' ORDER BY add_time DESC';
if ($num > 0)
{
$sql .= ' LIMIT ' . $num;
}
//echo $sql;
$res = $GLOBALS['db']->getAll($sql);
$ads = array();
foreach ($res AS $idx => $row)
{
$ads[$idx]['ad_name'] = $row['ad_name'];
$ads[$idx]['content'] = $row['content'];
$ads[$idx]['url'] = $row['url'];
}
return $ads;
}
}
$this->assign('my_ads',get_ads(9)); // 9代表会条数据
?>
<!-- nav middle right ad box div end -->
<div class="nav_leftbox">
<!-- nav left box menu div start -->
<div class="nav_leftmenu">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration le 5}-->
<span id="leftmenu_content{$smarty.foreach.ad_num.iteration}"<!-- {if $smarty.foreach.ad_num.iteration eq 1}--> style="display:block"<!-- {/if}-->><a href="{$ads.url}" target="_blank" title="{$ads.ad_name}"><img src="{$ads.content}" /></a></span>
<!-- {/if}-->
<!--{/foreach}-->
<div class="nav_lefttab">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration le 5}-->
<a id="leftmenu_tab{$smarty.foreach.ad_num.iteration}"<!-- {if $smarty.foreach.ad_num.iteration eq 1}--> class="thisselected"<!-- {/if}--> href="{$ads.url}" target="_blank" οnmοuseοver="chooseLeftMenu({$smarty.foreach.ad_num.iteration})"><font color="white">{$ads.ad_name}</font></a>
<!-- {/if}-->
<!--{/foreach}-->
</div>
</div>
</div>
<!-- nav left box menu div end -->
<script>
function chooseLeftMenu(id){
for (var i = 1; i <= 5; i++){
if (i == id){
$('leftmenu_tab'+i).className = 'thisselected';
$('leftmenu_content'+i).fade('in');
$('leftmenu_content'+i).style.display = 'block';
}else{
$('leftmenu_tab'+i).removeClass('thisselected');
$('leftmenu_content'+i).fade('out');
$('leftmenu_content'+i).style.display = 'none';
}
}
}
</script>
<div class="nav_middlebox">
<!-- nav middle focus box div start -->
<div id="f_a" class="focusimg">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration ge 6}-->
<!-- {if $smarty.foreach.ad_num.iteration eq 6}--><div style="display:block;"><!-- {else}--><div style="display:none;"><!-- {/if}--><a target="_blank" href="{$ads.url}"><img border="0" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto();" src="{$ads.content}"/></a></div>
<!-- {/if}-->
<!--{/foreach}-->
<div class="focusimg_number">
<table cellspacing="1" cellpadding="0" border="0" align="right" id="num_tag" height="30">
<tr>
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration ge 6}-->
<!-- {if $smarty.foreach.ad_num.iteration eq 6}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(0);" οnclick="Mea(0);" class="bigon">{$ads.ad_name}</td>
<!-- {elseif $smarty.foreach.ad_num.iteration eq 7}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(1);" οnclick="Mea(1);" class="bigoff">{$ads.ad_name}</td>
<!-- {elseif $smarty.foreach.ad_num.iteration eq 8}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(2);" οnclick="Mea(2);" class="bigoff">{$ads.ad_name}</td>
<!-- {else}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(3);" οnclick="Mea(3);" class="bigoff">{$ads.ad_name}</td>
<!-- {/if}-->
<!-- {/if}-->
<!--{/foreach}-->
</tr>
</table>
</div>
</div>
</div>
<!-- nav middle focus box div end -->
<script type="text/javascript">var n=0;var t=4;var showNum=document.getElementById("num_tag"); function Mea(value){n=value;setBg(value);plays(value);} function setBg(value){for(var i=0;i<t;i++)if(value==i){showNum.getElementsByTagName("td")[i].className='bigon';}else{showNum.getElementsByTagName("td")[i].className='bigoff';}} function plays(value){try{with(f_a){children[value].getElementsByTagName("img")[0].filters[0].Apply();for(i=0;i<t;i++)i==value?children[i].style.display="block":children[i].style.display="none";children[value].getElementsByTagName("img")[0].filters[0].Play();}}catch(e){var divlist=document.getElementById("f_a").getElementsByTagName("div");for(i=0;i<t;i++){i==value?divlist[i].style.display="block":divlist[i].style.display="none";}}} function clearAuto(k){clearInterval(autoStart);if(k != null)Mea(k);}function setAuto(){autoStart=setInterval("auto(n)", 5000);}function auto(){n++;if(n>t-1)n=0;Mea(n);}function sub(){n--;if(n<0)n=t-1;Mea(n);} setAuto();</script>
<!-- {/if} -->
这里加了个函数 get_ads,调用后台自定义广告zuimoban_ad_custom表,具体长高度自行替换!
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- {if $index_ad eq 'sys'} -->
<script type="text/javascript">
var swf_width=725;
var swf_height=300;
</script>
<script type="text/javascript" src="data/flashdata/{$flash_theme}/cycle_image.js"></script>
<!-- {elseif $index_ad eq 'cus'} -->
<?php
if(!function_exists("get_ads")){
function get_ads($num)
{
$sql = 'select * from '.$GLOBALS['ecs']->table('ad_custom').' ORDER BY add_time DESC';
if ($num > 0)
{
$sql .= ' LIMIT ' . $num;
}
//echo $sql;
$res = $GLOBALS['db']->getAll($sql);
$ads = array();
foreach ($res AS $idx => $row)
{
$ads[$idx]['ad_name'] = $row['ad_name'];
$ads[$idx]['content'] = $row['content'];
$ads[$idx]['url'] = $row['url'];
}
return $ads;
}
}
$this->assign('my_ads',get_ads(9)); // 9代表会条数据
?>
<!-- nav middle right ad box div end -->
<div class="nav_leftbox">
<!-- nav left box menu div start -->
<div class="nav_leftmenu">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration le 5}-->
<span id="leftmenu_content{$smarty.foreach.ad_num.iteration}"<!-- {if $smarty.foreach.ad_num.iteration eq 1}--> style="display:block"<!-- {/if}-->><a href="{$ads.url}" target="_blank" title="{$ads.ad_name}"><img src="{$ads.content}" /></a></span>
<!-- {/if}-->
<!--{/foreach}-->
<div class="nav_lefttab">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration le 5}-->
<a id="leftmenu_tab{$smarty.foreach.ad_num.iteration}"<!-- {if $smarty.foreach.ad_num.iteration eq 1}--> class="thisselected"<!-- {/if}--> href="{$ads.url}" target="_blank" οnmοuseοver="chooseLeftMenu({$smarty.foreach.ad_num.iteration})"><font color="white">{$ads.ad_name}</font></a>
<!-- {/if}-->
<!--{/foreach}-->
</div>
</div>
</div>
<!-- nav left box menu div end -->
<script>
function chooseLeftMenu(id){
for (var i = 1; i <= 5; i++){
if (i == id){
$('leftmenu_tab'+i).className = 'thisselected';
$('leftmenu_content'+i).fade('in');
$('leftmenu_content'+i).style.display = 'block';
}else{
$('leftmenu_tab'+i).removeClass('thisselected');
$('leftmenu_content'+i).fade('out');
$('leftmenu_content'+i).style.display = 'none';
}
}
}
</script>
<div class="nav_middlebox">
<!-- nav middle focus box div start -->
<div id="f_a" class="focusimg">
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration ge 6}-->
<!-- {if $smarty.foreach.ad_num.iteration eq 6}--><div style="display:block;"><!-- {else}--><div style="display:none;"><!-- {/if}--><a target="_blank" href="{$ads.url}"><img border="0" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto();" src="{$ads.content}"/></a></div>
<!-- {/if}-->
<!--{/foreach}-->
<div class="focusimg_number">
<table cellspacing="1" cellpadding="0" border="0" align="right" id="num_tag" height="30">
<tr>
<!--{foreach from=$my_ads item=ads name=ad_num}-->
<!-- {if $smarty.foreach.ad_num.iteration ge 6}-->
<!-- {if $smarty.foreach.ad_num.iteration eq 6}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(0);" οnclick="Mea(0);" class="bigon">{$ads.ad_name}</td>
<!-- {elseif $smarty.foreach.ad_num.iteration eq 7}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(1);" οnclick="Mea(1);" class="bigoff">{$ads.ad_name}</td>
<!-- {elseif $smarty.foreach.ad_num.iteration eq 8}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(2);" οnclick="Mea(2);" class="bigoff">{$ads.ad_name}</td>
<!-- {else}-->
<td align="center" width="130" style="cursor:pointer;" οnmοuseοut="setAuto();" οnmοuseοver="clearAuto(3);" οnclick="Mea(3);" class="bigoff">{$ads.ad_name}</td>
<!-- {/if}-->
<!-- {/if}-->
<!--{/foreach}-->
</tr>
</table>
</div>
</div>
</div>
<!-- nav middle focus box div end -->
<script type="text/javascript">var n=0;var t=4;var showNum=document.getElementById("num_tag"); function Mea(value){n=value;setBg(value);plays(value);} function setBg(value){for(var i=0;i<t;i++)if(value==i){showNum.getElementsByTagName("td")[i].className='bigon';}else{showNum.getElementsByTagName("td")[i].className='bigoff';}} function plays(value){try{with(f_a){children[value].getElementsByTagName("img")[0].filters[0].Apply();for(i=0;i<t;i++)i==value?children[i].style.display="block":children[i].style.display="none";children[value].getElementsByTagName("img")[0].filters[0].Play();}}catch(e){var divlist=document.getElementById("f_a").getElementsByTagName("div");for(i=0;i<t;i++){i==value?divlist[i].style.display="block":divlist[i].style.display="none";}}} function clearAuto(k){clearInterval(autoStart);if(k != null)Mea(k);}function setAuto(){autoStart=setInterval("auto(n)", 5000);}function auto(){n++;if(n>t-1)n=0;Mea(n);}function sub(){n--;if(n<0)n=t-1;Mea(n);} setAuto();</script>
<!-- {/if} -->
这里加了个函数 get_ads,调用后台自定义广告zuimoban_ad_custom表,具体长高度自行替换!
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法