下面讲一下如何把Ecshop网店系统的首页主广告修改为JS并带有排序功能,先来看看效果吧:
修改方法如下:
1、把library/index_ad.lbi 里代码替换成以下代码:
<meta http-equiv="Content-Type" content="text/html; charset=gbk"><script type="text/javascript" src="//archive.cnblogs.com/a/2717157/"http://www.mfwine.cn/themes/Genuine/myFocus/myfocus-2.0.1.min.js"></script><script type="text/javascript">//设置myFocus.set({id:'myFocus',//IDpattern:'mF_pconline',//风格time:5//切换时间间隔(秒)});</script><div id="myFocus"><!--焦点图盒子--><div class="loading"><img src="//archive.cnblogs.com/a/2717157/"themes/Genuine/myFocus/loading.gif" alt="请稍候..." /></div><!--载入画面(可删除)--><div class="pic"><!--图片列表--><ul><!--{foreach from=$index_adlist item=ads}--><li><a target="_blank" href="http://archive.cnblogs.com/a/2717157/"{$ads.url}"><img src="//archive.cnblogs.com/a/2717157/"{$ads.content}" alt="{$ads.ad_name}" /></a></li><!--{/foreach}--></ul></div></div>
2、修改index.php
在“?>”前加上以下代码:
function get_index_ad(){$sql = 'SELECT ad_type,content,ad_name,url,orderid FROM ' . $GLOBALS['ecs']->table("ad_custom") .'ORDER BY orderid ASC' ;$res = $GLOBALS['db']->getAll($sql);$ads = array();foreach ($res AS $adx => $row){$ads[$adx]['ad_type'] = $row['ad_type'];$ads[$adx]['content'] = $row['content'];$ads[$adx]['url'] = $row['url'];$ads[$adx]['ad_name'] = $row['ad_name'];}return $ads;}
在下面这段代码
$smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告
后加入
$smarty->assign('index_adlist', get_index_ad());
3、在“ecs_ad_custom”表下增加一个字段“orderid”
4、修改admin/flashplay.php
5、修改后台模板 admin/templates 下的三个文件
第4与5步的修改打包下载地址:http://www.028wz.net/mf.zip
本文摘自:028工作室
联系客服