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表,具体长高度自行替换!
猜你需要

豫ICP备2021026617号-1  豫公网安备:41172602000185   Copyright © 2021-2028 www.78moban.com/ All Rights Reserved

本站作品均来自互联网,转载目的在于传递更多信息,并不代表本站赞同其观点和对其真实性负责。如有侵犯您的版权,请联系 1565229909#qq.com(把#改成@),我们将立即处理。