织梦DedeCMS系统的首页有一个轮播图功能,可以在后台将需要的内容设置为首页轮播。但是织梦自带的这个功能是以Flash组件的形式来展现的,而现在的主流浏览器Chrome等已经明确表示将不再支持Flash,更不用说从来就不支持Flash的苹果iPhone等产品。我们可以通过修改让织梦以图片的方式来展现轮播图。
首先打开织梦首页模板,默认为:/templets/default/index.htm,找到如下代码:
<div class="flashnews">
<!-- size: 280px * 192px -->
<script language='javascript'>
linkarr = new Array();
picarr = new Array();
textarr = new Array();
var swf_width=280;
var swf_height=192;
//文字颜色|文字位置|文字背景颜色|文字背景透明度|按键文字颜色|按键默认颜色|按键当前颜色|自动播放时间|图片过渡效果|是否显示按钮|打开方式
var configtg='0xffffff|0|0x3FA61F|5|0xffffff|0xC5DDBC|0x000033|2|3|1|_blank';
var files = "";
var links = "";
var texts = "";
//这里设置调用标记
{dede:arclist flag='f' row='5'}
linkarr[[field:global.autoindex/]] = "[field:arcurl/]";
picarr[[field:global.autoindex/]] = "[field:litpic/]";
textarr[[field:global.autoindex/]] = "[field:title function='html2text(@me)'/]";
{/dede:arclist}
for(i=1;i<picarr.length;i++){
if(files=="") files = picarr[i];
else files += "|"+picarr[i];
}
for(i=1;i<linkarr.length;i++){
if(links=="") links = linkarr[i];
else links += "|"+linkarr[i];
}
for(i=1;i<textarr.length;i++){
if(texts=="") texts = textarr[i];
else texts += "|"+textarr[i];
}
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="{dede:global.cfg_templeturl /}/default/images/bcastr3.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+'&bcastr_config='+configtg+'">');
document.write('<embed src="{dede:global.cfg_templeturl /}/default/images/bcastr3.swf" wmode="opaque" FlashVars="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'&bcastr_config='+configtg+'&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>
</div>
<!-- /flashnews -->
将这一段代码替换为:
<!-- 轮播start -->
<div id="sbox">
<div id="simg">
<div class="prev1" id="prev1"></div>
<div class="next1" id="next1"></div>
<ul>
{dede:arclist titlelen='66' flag='f' row='5'}
<li><a href="[field:arcurl/]" target="_blank"><img src="[field:litpic/]" /><em></em>
<h2>[field:title/]</h2>
</a></li>
{/dede:arclist}
</ul>
</div>
</div>
<!-- 轮播end -->
对应的CSS代码为:
/*图片轮播*/
#sbox { width: 370px; height: 300px; overflow: hidden; position: relative; zoom: 1; }
#simg { width: 370px; height: 300px; overflow: hidden; }
#simg ul { overflow: hidden; zoom: 1; position: absolute; top: 0px; left: 0px; width: 9999px; }
#simg ul li { overflow: hidden; zoom: 1; float: left; display: inline; width: 370px; height: 300px; }
#simg ul li h2 { z-index: 3; position: absolute; font-size: 16px; width: 370px; color: #fff; top: 255px; font-weight: bold; text-align: center; height: 35px; line-height: 35px; overflow: hidden; }
#simg ul li img { width: 370px; height: 300px; }
#simg ul li em { width: 370px; height: 200px; background: url(../images/scroll_bg.png) 0px 0px; position: absolute; top: 260px; z-index: 1; display: block; }
#simg_s { width: 273px; position: absolute; bottom: 9px; left: 51px; height: 71px; overflow: hidden; zoom: 1; z-index: 2; }
#simg_s ul { overflow: hidden; zoom: 1; width: 999px; position: absolute; top: 0px; left: 0px; }
#simg_s ul li { float: left; display: inline; width: 54px; height: 67px; overflow: hidden; zoom: 1; margin-right: 12px; border: 2px solid #333; }
#simg_s ul li.on { border: 2px solid #ff9500; }
#simg_s ul li img { width: 54px; height: 67px; }
.prev1 { position: absolute; top: 133px; left: 0px; width: 47px; height: 80px; z-index: 9; cursor: pointer; background: url(../images/yx_index.png) -3px -2px no-repeat; opacity: .3; }
.next1 { position: absolute; top: 133px; right: 0px; width: 45px; height: 78px; z-index: 9; cursor: pointer; background: url(../images/yx_index.png) -52px -4px no-repeat; opacity: .3; }
.prev1:hover, .next1:hover { opacity: .6; }
本站原创内容,如需转载请注明来源:https://www.liutonghui.com/159.html
评论列表(4条)
现在还有用织梦的吗!
回复 liyabin:老用户很多的
很好用,给我的网站替换了
回复 最爱水蜜桃:加油!