您的位置:首页 > 运维架构

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: