您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop二次开发笔记

卫耿羿2025-01-10Ecshop商城教程已有人查阅

导读\includes\lib_commom.php =>公用函数库\includes\lib_main.php =>前台公用函数库\includes\lib_init.php =>初始化,供/index.php调用

\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传参形式
模板:
<!-- {foreach name=nav_middle_list from=$navigator_list.middle item=nav} -->
smarty:$smarty->assign('navigator_list', get_navigator($ctype, $catlist));
模板里引用的from值[middle]就是参数
【smarty->display函数的用法】
根据id显示不同页面:
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中的<br>
过滤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遍历
<!-- {foreach from=$properties item=arr1} -->
<!-- {foreach from=$arr1 item=arr2} -->
<!--{if $arr2.name == '舒适性' || $arr2.name == '隔音性' || $arr2.name == '高音' || $arr2.name == '中音' || $arr2.name == '低音' || $arr2.name == '辨识度'}-->
<li>
<span>{$arr2.name}:</span>
<img src="images/goods-r-pj{$arr2.value}.jpg" alt="">
</li>
<!--{/if}-->
<!-- {/foreach} -->
<!-- {/foreach} -->
留言板二次开发:
完成功能:
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>

本文标签:

很赞哦! ()

相关源码

  • pbootcms模板(自适应手机版)红色响应式单位机构类网站自适应响应式单位机构网站模板 | PbootCMS内核开发为机构组织设计的响应式网站模板,采用PbootCMS内核开发,支持一键替换行业内容,满足多元化场景需求。查看源码
  • (自适应)品牌策划网络设计作品公司个人pbootcms网站源码下载本款基于PbootCMS开发的网站模板专为品牌策划、设计公司打造,特别适合展示创意作品、设计案例和企业服务。模板采用现代化设计风格查看源码
  • (自适应)工业机械设备产品介绍免费pbootcms源码下载本网站模板基于PbootCMS内核精心开发,为机械设备与工业产品制造企业量身打造。设计充分考量行业特性,突出产品展示与技术实力呈现查看源码
  • 帝国CMS游戏应用APP推广下载站模板免费下载本模板为移动应用推广、手机游戏推广行业设计,集成H5游戏平台与APP下载功能,支持PC端与移动端自适应访问。专注于为应用开发商、游戏发行商提供专业的线上推广展示平台。查看源码
  • (自适应)APP应用软件落地页单页推广页网站模板下载基于PbootCMS内核开发的响应式单页模板,为企业产品展示、服务推广等应用场景设计。通过简洁直观的视觉布局与高效的技术架构,帮助用户快速构建专业级落地页面,实现移动端与PC端数据实时同步展示。查看源码
  • (自适应响应式)环保水净化处理设备阀门等网站源码下载基于PbootCMS内核开发的响应式模板,为水处理设备、空气净化器等环保企业设计,自适应手机端浏览。通过简洁高效的后台管理系统,助力环保科技企业快速建立专业在线展示平台。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐