下面讲一下如何把ecshop网店系统的首页主广告修改为JS并带有排序功能,先来看看效果吧:
修改方法如下:
1、把library/index_ad.lbi 里代码替换成以下代码:
<meta http-equiv="Content-Type" content="text/HTML; charset=gbk"><script type="text/javascript" src="http://www.mfwine.cn/themes/Genuine/myFocus/myfocus-2.0.1.min.js">script><script type="text/javascript">//设置myFocus.set({ id:'myFocus',//ID pattern:'mF_pconline',//风格 time:5//切换时间间隔(秒)});script><div id="myFocus"> <div class="loading"><img src="themes/Genuine/myFocus/loading.gif" alt="请稍候..." />div> <div class="pic"> <ul> <li><a target="_blank" href="{$ads.url}"><img src="{$ads.content}" alt="{$ads.ad_name}" />a></li> 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 下的三个文件
- flashplay_custom.htm
- flashplay_custom_add.htm
- flashplay_ccustom_edit.htm
第4与5步的修改打包下载地址:http://www.028wz.net/mf.zip