• 技术文章 >php教程 >php手册

    ECSHOP二次开发杂记(一),ecshop二次开发杂记

    2016-06-13 09:11:51原创315

    ECSHOP二次开发杂记(一),ecshop二次开发杂记


    \includes\lib_commom.php =>公用函数库

    \includes\lib_main.php =>前台公用函数库

    \includes\lib_init.php =>初始化,供/index.php调用

    \includes\lib_insert.php =>动态内容函数库 模板{insert name='ads' id=$ads_id num=$ads_num} 所调用的函数即是 function insert_ads

    \includes\cls_template.php =>含有格式化函数 模板{$goods.name|escape:html}

    \includes\inc_constant.php=>常量定义

    【foreach的使用方法】

    1:foreach使用规则,他有以下几个参数 from ,item name iteration index

    2:如何使用foreach循环

      如果php要传递一个数组(如:$array)给ecshop的smarty模板.那么我们将通过from=$array 来接受,写法是{foreach from = $array item = item}

    3:
    ecshop中smarty的下标如何表示,请看下面的例子:
    {foreach from = $array item = item name=name}
    {$smarty.foreach.name.iteration}
    {/foreach}

    这里的iteration就是从1开始的下标,
    如果要从0开始的下标,应该使用{$smarty.foreach.name.index}

    4:如何判断是否是foreach循环的开始和结束,最后一个元素.

    {if $smarty.foreach.last}表示循环的最后一个元素.{if $smarty.freach.first}表示循环的开始.

    5:如何使用双重循环.

    举例如下:

    {foreach from = $test item =item}

    {foreach from=$item.children item=child}
    {$child.name}
    {/foreach}
    {/foreach}

    6:from传参形式

    模板:

    smarty:$smarty->assign('navigator_list', get_navigator($ctype, $catlist));

    模板里引用的from值[middle]就是参数

    【smarty->display函数的用法】

    根据id显示不同页面:

    http://127.0.0.13/article_cat.php?id=6

    http://127.0.0.13/article_cat.php?id=7

    if($cat_id==6){
    $smarty->display('article_cat_xgzn.dwt', $cache_id);
    }elseif($cat_id==7){
    $smarty->display('article_cat_boke.dwt', $cache_id);
    }else{
    $smarty->display('article_cat.dwt', $cache_id);
    }

    【小技巧】

    转换UNIX时间戳: $goods[$idx]['sj_date'] = date($GLOBALS['_CFG']['date_format'], $row['sj_date']);

    文本格式化:{$cat_goods.name|escape:html}

    字符串截取:{$brand.brand_desc|truncate:11}、{$article.short_title|truncate:15:"...":true}

    处理换行:{$title|nl2br}将php中的换行符变成HTML中的

    过滤HTML标签:{$title|strip_tags}

    goods.dwt大图:{$pictures.0.img_url}

    【后台模板二次开发】

    1.增加商品属性:

    a.向数据表(*_goods)添加字段(sj_date)。

    b.向模板(admin/templates/goods_info.htm)添加

    c.向后台提交数据处理函数添加字段进行入库(admin/goods.php)。

    d.前台显示函数进行处理(includes\lib_goods.php)。

    2.设置后台模板[商品分类页模板]增加新品上架:

    a.向数据表(*_template)新增记录

    b.向/admin/includes/lib_template.php添加新增的库 (3代表可编辑数量)

    3.在模板中多维数组的遍历:

    a.数组原型:print_r打印

    $smarty->assign('properties', $properties['pro']); // 商品属性 print_r($properties['pro']);=>Array ( [技术参数] => Array ( [1] => Array ( [name] => 连接 [value] => 3.5mm/6.3mm ) [2] => Array ( [name] => 佩戴方式 [value] => 头戴式 ) [3] => Array ( [name] => 特性 [value] => 主动降噪 ) ) ) View Code

    b.模板foreach遍历

    <li> <span>{$arr2.name}:span> <img src="images/goods-r-pj{$arr2.value}.jpg" alt=""> li> View Code

    留言板二次开发:

    完成功能:

    1.\includes\inc_constant.php line:129 添加 define('M_SELL', 7); // 出售

    2.\languages\zh_cn\common.php line:634 添加 $_LANG['message_type'][M_SELL] = '出售';

    3.\languages\zh_cn\admin\user_msg.php line:35 修改 $_LANG['type'] = array('留言','投诉','询问','售后','求购','商家留言','评论','出售');//注意下标

    4.向数据表(*_feedback)添加字段

    5./message.php line:72 $message数组中接收页面传递的数据

    6./includes/lib_clips.php line:197 $sql中添加向数据库插入字段

    7.后台查看显示 更改模板msg_info.htm

    <div class="hg150317"> <ul> <li><span>商品名称:span>{$msg.msg_title|escape:"html"}li> <li><span>商品型号:span>{$msg.goods_type|escape:"html"}li> <li><span>出售价格:span>{$msg.goods_price}li> <li><span>姓名:span>{$msg.user_name}li> <li><span>邮箱:span>{$msg.user_email}li> <li><span>证件类型:span>{if $msg.papers_type==0}身份证{elseif $msg.papers_type==1}护照{elseif $msg.papers_type==2}驾驶证{else}台胞证{/if}li> <li><span>证件号:span>{$msg.paper_number}li> <li><span>电话:span>{$msg.tel}li> <li><span>地址:span>{$msg.address}li> <li><span>备注:span>{$msg.msg_content|escape:"html"|nl2br}li> ul> div> View Code
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:ecshop
    php培训_php实战培训【立即报名】-php中文网第20期

    相关文章推荐

    • 【活动】充值PHP中文网VIP即送云服务器• PHP随机生成信用卡卡号的方法,php信用卡卡号• drupal7创始人root忘记密码的解决办法,drupal7root• 遵循PSR-4的自动加载,遵循PSR-4加载• php批量添加数据与批量更新数据的实现方法,php添加数据• Codeigniter的一些优秀实践
    1/1

    PHP中文网