ECSHOP二次開發雜記(一),ecshop二次開發雜記_PHP教程

來源:互聯網
上載者:User

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

http://www.bkjia.com/PHPjc/969245.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/969245.htmlTechArticleECSHOP二次開發雜記(一),ecshop二次開發雜記 \includes\lib_commom.php =公用函數庫 \includes\lib_main.php =前台公用函數庫 \includes\lib_init.php =初始化,供...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.