ecshop二次开发

编程入门 行业动态 更新时间:2024-10-07 16:17:25

<a href=https://www.elefans.com/category/jswz/34/1764724.html style=ecshop二次开发"/>

ecshop二次开发

案例效果:(即在指定的节假日的时候会有指定的活动)






案例实现:

1.先找到 ecshop/languages/zh_cn/admin/common.PHP文件,

然后在文件中加入代码:

[python] view plain copy
  1. $_LANG['17_business_manage'] = '商务管理';  
[python] view plain copy
  1. $_LANG['04_festival_list'] = '节日列表';  
  2. $_LANG['05_festival_add'] = '添加节日';  




2.再找到 ecshop/admin/includes/inc_menu.php文件,

在文件中的最后一行加入代码:

[python] view plain copy
  1. //商务管理  
  2. $modules['17_business_manage']['04_festival_list']        = 'festival_list.php?act=list';  
  3. $modules['17_business_manage']['05_festival_add']        = 'festival_list.php?act=insert';  





3.在ecshop数据库中添加节日表ecs_festival,

(其中act_id是优惠活动表ecs_favourable_activity中的 act_id)







4.在 ecshop/admin/ 下建立festival_list.php

[python] view plain copy
  1. <?php  
  2.   
  3. /**  
  4.  * ECSHOP 邮件列表管理  
  5.  * ===========================================================  
  6.  * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。  
  7.  * 网站地址: ;  
  8.  * ----------------------------------------------------------  
  9.  * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和  
  10.  * 使用;不允许对程序代码以任何形式任何目的的再发布。  
  11.  * ==========================================================  
  12.  * $Author: liubo $  
  13.  * $Id: email_list.php 17217 2011-01-19 06:29:08Z liubo $  
  14.  */  
  15. define('IN_ECS', true);  
  16. require(dirname(__FILE__) . '/includes/init.php');  
  17. admin_priv('email_list');  
  18.   
  19. if ($_REQUEST['act'] == 'list')  
  20. {  
  21.     $emaildb = get_email_list();  
  22.     $smarty->assign('full_page',    1);  
  23.     $smarty->assign('ur_here', $_LANG['email_list']);  
  24.     $smarty->assign('emaildb',      $emaildb['emaildb']);  
  25.     $smarty->assign('filter',       $emaildb['filter']);  
  26.     $smarty->assign('record_count', $emaildb['record_count']);  
  27.     $smarty->assign('page_count',   $emaildb['page_count']);  
  28.     assign_query_info();  
  29.     $sql = "select * from ". $ecs->table('festival') ." as a left join ". $ecs->table('favourable_activity') ." as b on a.act_id=b.act_id";  
  30.     $fes = $db->getAll($sql);  
  31.     $smarty->assign('festival_add', "添加节日");  
  32.     $smarty->assign('fes_id', "编号");  
  33.     $smarty->assign('fes_name', "节日名称");  
  34.     $smarty->assign('fes_date', "节日时间");  
  35.     $smarty->assign('fes_addtime', "节日添加时间");  
  36.     $smarty->assign('act_name', "活动名称");  
  37.     $smarty->assign('fes', $fes);  
  38.     $smarty->display('festival_list.htm');  
  39.     //$smarty->display('email_list.htm');  
  40. }elseif($_REQUEST['act'] == 'insert')  
  41. {  
  42.     $smarty->assign('fes_name', "节日名称");  
  43.     $smarty->assign('fes_date', "节日时间");  
  44.     $smarty->assign('act_name', "活动名称");  
  45.     $sql = "select act_id,act_name from ". $ecs->table('favourable_activity');  
  46.     $act = $db->getAll($sql);  
  47.     $smarty->assign('act', $act);  
  48.     $smarty->display('festival_add.htm');  
  49. }  
  50. elseif($_REQUEST['act'] == 'form_pro')  
  51. {  
  52.     $fes_name = $_POST['fes_name'];  
  53.     $fes_date = $_POST['fes_date'];  
  54.     $act_id = $_POST['act_id'];  
  55.     $fes_addtime = date("Y-m-d H:i:s");  
  56.     $sql = "insert into ". $ecs->table('festival') ." values(null,'$fes_name','$fes_date','$fes_addtime','$act_id')";  
  57.     $res = $db->query($sql);  
  58.     if($res){  
  59.         /**  
  60.          * start  
  61.          */  
  62.         $emaildb = get_email_list();  
  63.         $smarty->assign('full_page',    1);  
  64.         $smarty->assign('ur_here', $_LANG['email_list']);  
  65.         $smarty->assign('emaildb',      $emaildb['emaildb']);  
  66.         $smarty->assign('filter',       $emaildb['filter']);  
  67.         $smarty->assign('record_count', $emaildb['record_count']);  
  68.         $smarty->assign('page_count',   $emaildb['page_count']);  
  69.         assign_query_info();  
  70.         /**  
  71.          * end  
  72.          */  
  73.         $sql = "select * from ". $ecs->table('festival') ." as a left join ". $ecs->table('favourable_activity') ." as b on a.act_id=b.act_id";  
  74.         $fes = $db->getAll($sql);  
  75.         $smarty->assign('festival_add', "添加节日");  
  76.         $smarty->assign('fes_id', "编号");  
  77.         $smarty->assign('fes_name', "节日名称");  
  78.         $smarty->assign('fes_date', "节日时间");  
  79.         $smarty->assign('fes_addtime', "节日添加时间");  
  80.         $smarty->assign('act_name', "活动名称");  
  81.         $smarty->assign('fes', $fes);  
  82.         $smarty->display("festival_list.htm");  
  83.     }else{  
  84.         $smarty->display("festival_add.htm");  
  85.     }  
  86. }  
  87.   
  88.   
  89. elseif ($_REQUEST['act'] == 'export')  
  90. {  
  91.     $sql = "SELECT email FROM " . $ecs->table('email_list') . "WHERE stat = 1";  
  92.     $emails = $db->getAll($sql);  
  93.     $out = '';  
  94.     foreach ($emails as $key => $val)  
  95.     {  
  96.         $out .= "$val[email]\n";  
  97.     }  
  98.     $contentType = 'text/plain';  
  99.     $len = strlen($out);  
  100.     header('Last-Modified: ' . gmdate('D, d M Y H:i:s',time()+31536000) .' GMT');  
  101.     header('Pragma: no-cache');  
  102.     header('Content-Encoding: none');  
  103.     header('Content-type: ' . $contentType);  
  104.     header('Content-Length: ' . $len);  
  105.     header('Content-Disposition: attachment; filename="email_list.txt"');  
  106.     echo $out;  
  107.     exit;  
  108. }  
  109. elseif ($_REQUEST['act'] == 'query')  
  110. {  
  111.     $emaildb = get_email_list();  
  112.     $smarty->assign('emaildb',      $emaildb['emaildb']);  
  113.     $smarty->assign('filter',       $emaildb['filter']);  
  114.     $smarty->assign('record_count', $emaildb['record_count']);  
  115.     $smarty->assign('page_count',   $emaildb['page_count']);  
  116.   
  117.     $sort_flag  = sort_flag($emaildb['filter']);  
  118.     $smarty->assign($sort_flag['tag'], $sort_flag['img']);  
  119.   
  120.     make_json_result($smarty->fetch('email_list.htm'), '',  
  121.         array('filter' => $emaildb['filter'], 'page_count' => $emaildb['page_count']));  
  122. }  
  123.   
  124. /*------------------------------------------------------ */  
  125. //-- 批量删除  
  126. /*------------------------------------------------------ */  
  127. elseif ($_REQUEST['act'] == 'batch_remove')  
  128. {  
  129.     if (!isset($_POST['checkboxes']) || !is_array($_POST['checkboxes']))  
  130.     {  
  131.         sys_msg($_LANG['no_select_email'], 1);  
  132.     }  
  133.   
  134.     $sql = "DELETE FROM " . $ecs->table('email_list') .  
  135.             " WHERE id " . db_create_in(join(',', $_POST['checkboxes']));  
  136.     $db->query($sql);  
  137.   
  138.     $lnk[] = array('text' => $_LANG['back_list'], 'href' => 'email_list.php?act=list');  
  139.     sys_msg(sprintf($_LANG['batch_remove_succeed'], $db->affected_rows()), 0, $lnk);  
  140. }  
  141.   
  142. /*------------------------------------------------------ */  
  143. //-- 批量恢复  
  144. /*------------------------------------------------------ */  
  145. elseif ($_REQUEST['act'] == 'batch_unremove')  
  146. {  
  147.     if (!isset($_POST['checkboxes']) || !is_array($_POST['checkboxes']))  
  148.     {  
  149.         sys_msg($_LANG['no_select_email'], 1);  
  150.     }  
  151.   
  152.     $sql = "UPDATE " . $ecs->table('email_list') .  
  153.             " SET stat = 1 WHERE stat <> 1 AND id " . db_create_in(join(',', $_POST['checkboxes']));  
  154.     $db->query($sql);  
  155.   
  156.     $lnk[] = array('text' => $_LANG['back_list'], 'href' => 'email_list.php?act=list');  
  157.     sys_msg(sprintf($_LANG['batch_unremove_succeed'], $db->affected_rows()), 0, $lnk);  
  158. }  
  159.   
  160. /*------------------------------------------------------ */  
  161. //-- 批量退订  
  162. /*------------------------------------------------------ */  
  163. elseif ($_REQUEST['act'] == 'batch_exit')  
  164. {  
  165.     if (!isset($_POST['checkboxes']) || !is_array($_POST['checkboxes']))  
  166.     {  
  167.         sys_msg($_LANG['no_select_email'], 1);  
  168.     }  
  169.   
  170.     $sql = "UPDATE " . $ecs->table('email_list') .  
  171.             " SET stat = 2 WHERE stat <> 2 AND id " . db_create_in(join(',', $_POST['checkboxes']));  
  172.     $db->query($sql);  
  173.   
  174.     $lnk[] = array('text' => $_LANG['back_list'], 'href' => 'email_list.php?act=list');  
  175.     sys_msg(sprintf($_LANG['batch_exit_succeed'], $db->affected_rows()), 0, $lnk);  
  176. }  
  177.   
  178. function get_email_list()  
  179. {  
  180.     $result = get_filter();  
  181.     if ($result === false)  
  182.     {  
  183.         $filter['sort_by']      = empty($_REQUEST['sort_by']) ? 'stat' : trim($_REQUEST['sort_by']);  
  184.         $filter['sort_order']   = empty($_REQUEST['sort_order']) ? 'ASC' : trim($_REQUEST['sort_order']);  
  185.   
  186.         $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('email_list');  
  187.         $filter['record_count'] = $GLOBALS['db']->getOne($sql);  
  188.   
  189.         /* 分页大小 */  
  190.         $filter = page_and_size($filter);  
  191.   
  192.         /* 查询 */  
  193.   
  194.         $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('email_list') .  
  195.             " ORDER BY " . $filter['sort_by'] . ' ' . $filter['sort_order'] .  
  196.             " LIMIT " . $filter['start'] . ",$filter[page_size]";  
  197.   
  198.         set_filter($filter, $sql);  
  199.     }  
  200.     else  
  201.     {  
  202.         $sql    = $result['sql'];  
  203.         $filter = $result['filter'];  
  204.     }  
  205.   
  206.     $emaildb = $GLOBALS['db']->getAll($sql);  
  207.   
  208.     $arr = array('emaildb' => $emaildb, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);  
  209.   
  210.     return $arr;  
  211.   
  212.   
  213. }  
  214. ?>  

7、在ecshop/admin/templates中将user_info.htm文件复制并重命名为festival_add.htm。

[python] view plain copy
  1. <form method="post" action="festival_list.php?act=form_pro" name="theForm" οnsubmit="return validate()">  
  2.     <table width="100%">  
  3.         <tr>  
  4.             <td class="label" align="center">{$fes_name}:</td>  
  5.             <td><input type="text" name="fes_name" maxlength="60" /></td>  
  6.         </tr>  
  7.         <tr>  
  8.             <td class="label" align="center">{$fes_date}:</td>  
  9.             <td><input type="text" name="fes_date" maxlength="60" /></td>  
  10.         </tr>  
  11.         <tr>  
  12.             <td class="label" align="center">{$act_name}:</td>  
  13.             <td>  
  14.                 <select name="act_id">  
  15.                     <option value="">======请选择======</option>  
  16.                     {foreach from=$act item=val}  
  17.                     <option value="{$val.act_id}">{$val.act_name}</option>  
  18.                     {/foreach}  
  19.                 </select>  
  20.             </td>  
  21.         </tr>  
  22.         <tr>  
  23.             <td colspan="2" align="center">  
  24.                 <input type="submit" value="{$lang.button_submit}" class="button" />  
  25.                 <input type="reset" value="{$lang.button_reset}" class="button" />  
  26.             </td>  
  27.         </tr>  
  28.     </table>  
  29. </form>  

前台展示

找到前台文件ecshop/index.php






[python] view plain copy
  1. //节日列表  
  2. $date=date("m-d",time());  
  3. //var_dump($date);die;  
  4. $sql = "select * from ". $ecs->table('festival') ." as a left join ". $ecs->table('favourable_activity') ." as b on a.act_id=b.act_id where fes_date = '$date' order by fes_addtime desc limit 5";  
  5. $fes = $db->getAll($sql);  
  6. $smarty->assign('fes', $fes);  


再找到upload\themes\default中的前台模板index.dwt













[python] view plain copy
  1. <style type="text/css">  
  2.   
  3.   #fes_div{padding-left:20px; padding-top:10px; padding-bottom:10px; border-bottom:1px solid gray;}  
  4.   
  5.   #fes_a{text-decoration:none; color:green; font-size:16px; font-family:'楷体';}  
  6.   
  7.   #fes_a:hover{color:red; font-weight:bold; text-decoration:underline;}  
  8.   
  9.   #fes_span{margin-right:10px; color:gray; float:right;}  
  10.   
  11. </style>  
  12.   
  13.    
  14.   
  15. <div class="box">  
  16.   
  17. <div class="box_1">  
  18.   
  19. <h3><span>节日列表</span></h3>  
  20.   
  21. <div class="boxCenterList RelaArticle">  
  22.   
  23.     {foreach from=$fes item=val}  
  24.   
  25. <div id="fes_div"><a href="javascript:;" id="fes_a">  {$val.fes_name}</a><span id="fes_span">{$val.fes_date}</span></div>  
  26.   
  27.     {/foreach}  
  28.   
  29. </div>  
  30.   
  31. </div>  
  32.   
  33. </div>  


更多推荐

ecshop二次开发

本文发布于:2024-02-19 15:09:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1764602.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ecshop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!