ecshop的一些东西,来看看
2015-03-18 15:02
218 查看
\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显示不同页面:
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中的<br>
过滤HTML标签:{$title|strip_tags}
goods.dwt大图:{$pictures.0.img_url}
【后台模板二次开发】
1.增加商品属性:
View Code
b.模板foreach遍历
View Code
留言板二次开发:
完成功能:
View Code
\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显示不同页面:
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中的<br>
过滤HTML标签:{$title|strip_tags}
goods.dwt大图:{$pictures.0.img_url}
【后台模板二次开发】
1.增加商品属性:
View Code
b.模板foreach遍历
View Code
留言板二次开发:
完成功能:
View Code
相关文章推荐
- <转>整理知乎上的一些指点前路的东西(计算机系可以看看,别把四年浪费了)
- 关于前端的一些东西--记住了一些,闲时再看看
- 整理知乎上的一些指点前路的东西(计算机系可以看看,别把四年浪费了)
- Java编写中容易搞错的一些东西
- 关于Intent Flag相关的一些东西
- oracle的笔记,凑合着看吧!3 比较杂烩的一些东西
- 关于Oracle字符拼接的一些东西
- java的一些东西
- 一个内部类的使用,学到了一些东西...
- 关于RN中FlatList的一些东西,以及FlatList为什么会得到多个只显示几个信息的原因
- 整理一下之前工作中记录过的一些东西——4gl
- 【转】css的一些基础的东西
- Asp.net必须掌握的一些东西(2)(转)
- 細微之處看看mysql與sql server的一些差別
- Android 2016的一些新东西
- 【总有一些东西要弄清】——说说面试时一系列的CSS问题
- ecshop安全方面的一些参考建议
- 想想学习C已经有9年了, 应该可以写一些东西了.——转
- 一些很简单但是很重要的东西
- 一些可以运行到的东西