详情页

ECSHOP二次开发杂记(一)

时间:2023年06月01日

编辑:佚名

ecshop二次开发杂记
        \includes\lib_commom.php=>公用函数库
        \includes\lib_main.php=>前台公用函数库
        \includes\lib_init.php=>初始化,供/index.php调用
        \includes\lib_insert.php=>动态内容函数库 模板{insertname=adsid=$ads_idnum=$ads_num}所调用的函数即是functioninsert_ads
        \includes\cls_template.php=>含有格式化函数 模板{$goods.name|escape:html}
        \includes\inc_constant.php=>常量定义
        foreach使用方法】
        1:foreach使用规则,有以下几个参数 from,itemnameiterindex
        2:如何使用foreach循环
        如果php要传送一个数组(如:$arrai给ecshopsmarti模板.那么我将通过from=$arrai来接受,写法是{foreachfrom=$arraiitem=item}
        3:
ecshop中smarti下标如何表示,请看下面的例子:
{foreachfrom=$arraiitem=itemname=name}
{$smarty.foreach.name.iteration}
{/foreach}
这里的iter就是从1开始的下标,
如果要从0开始的下标,应该使用{$smarty.foreach.name.index}
        4:如何判断是否是foreach循环的开始和结束,最后一个元素.
        {if$smarty.foreach.last}表示循环的最后一个元素.{if$smarty.freach.first}表示循环的开始.
        5:如何使用双重循环.
        举例如下:
        {foreachfrom=$testitem=item}
        {foreachfrom=$item.childrenitem=child}
{$child.name}
{/foreach}
{/foreach}
        6:from传参形式
        模板:
        smarti$smarty->assignnavigator_list,get_navig$ctype,$catlist;
        模板里引用的from值[middle]就是参数
        smarty->displai函数的用法】
        根据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->displaiarticle_cat_xgzn.dwt,$cache_id;
}elseif$cat_id==7{
$smarty->displaiarticle_cat_boke.dwt,$cache_id;
}else{
$smarty->displaiarticle_cat.dwt,$cache_id;
}
        小技巧】
        转换UNIX时间戳:$goods[$idx][sj_date]=date$GLOBA LS[_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.向数据表(*_good添加字段(sj_date
        b.向模板(admin/templates/goods_info.htm添加
        c.向后台提交数据处置函数添加字段进行入库(admin/goods.php
        d.前台显示函数进行处置(includes\lib_goods.php
        2.设置后台模板[商品分类页模板]增加新品上架:
        a.向数据表(*_templat新增记录
        b.向/admin/includes/lib_template.php添加新增的库 3代表可编辑数量)
        3.模板中多维数组的遍历:
        a.数组原型:print_r打印
$smarty->assignproperties,$properties[pro];//商品属性print_r$properties[pro];=>A rray[技术参数]=>A rray[1]=>A rray[name]=>连接 [value]=>3.5mm/6.3mm[2]=>A rray[name]=>佩戴方式 [value]=>头戴式 [3]=>A rray[name]=>特性 [value]=>主动降噪 ViewCode
        b.模板foreach遍历
<li><span>{$arr2.name}span><imgsrc="images/goods-r-pj{$arr2.value}.jpg"alt="">li>ViewCode
        留言板二次开发:
        完成功能:
        1.\includes\inc_constant.phpline:129添加 definM_SELL,7;//出卖
        2.\languages\zh_cn\common.phpline:634添加 $_LA NG[message_type][M_SELL]=出卖;
        3.\languages\zh_cn\admin\user_msg.phpline:35修改 $_LA NG[type]=arrai留言,投诉,询问,售后,求购,商家留言,评论,出卖;//注意下标
        4.向数据表(*_feedback添加字段
        5./message.phpline:72$messag数组中接收页面传送的数据
        6./includes/lib_clips.phpline:197$sql中添加向数据库拔出字段
        7.后台检查显示 更改模板msg_info.htm
<pclass="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>p>
相关文章
猜你需要