ECSHOP secondary development Note (1), ecshop secondary development NOTE _ PHP Tutorial

Source: Internet
Author: User
Tags constant definition
ECSHOP secondary development Note (1): ecshop secondary development note. ECSHOP secondary development Note (1): ecshop secondary development note includeslib_commom.php public function library includeslib_main.php front-end public function library includeslib_init.php initialization, for ECSHOP secondary development Note (1), ecshop secondary development note

\ Mongodes \ lib_commom.php => Public Function Library

\ Shortdes \ lib_main.php => front-end public function library

\ Includes \ lib_init.php => initialization for/index. php

\ Includes \ lib_insert.php => The function called by the dynamic content library template {insert name = 'ads' id = $ ads_id num = $ ads_num} is function insert_ads.

\ Shortdes \ cls_template.php => contains the formatting function template {$ goods. name | escape: html}

\ Shortdes \ inc_constant.php => constant definition

[Usage of foreach]

1: foreach rules. it has the following parameters: from, item name iteration index

2: how to use the foreach loop

If php wants to pass an array (for example, $ array) to the smarty template of ecshop. then we will accept it through from = $ array. The syntax is {foreach from = $ array item = item}

3:
The following example shows how to express the subscript of smarty in ecshop:
{Foreach from = $ array item = item name = name}
{$ Smarty. foreach. name. iteration}
{/Foreach}

Here iteration is the subscript starting from 1,
To subscripts starting from 0, use {$ smarty. foreach. name. index}

4: determine whether it is the beginning and end of a foreach loop, and the last element.

{If $ smarty. foreach. last} indicates the last element of the loop. {if $ smarty. freach. first} indicates the start of the loop.

5: how to use dual loop.

Example:

{Foreach from = $ test item = item}

{Foreach from = $ item. children item = child}
{$ Child. name}
{/Foreach}
{/Foreach}

6: from parameter passing

Template:

Smarty: $ smarty-> assign ('Navigator _ list', get_navigator ($ ctype, $ catlist ));

The from value [middle] referenced in the template is a parameter.

[Usage of smarty-> display function]

Display different pages by 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 );
}

Tips]

UNIX timestamp for conversion:$ Goods [$ idx] ['SJ _ date'] = date ($ GLOBALS ['_ CFG'] ['date _ format'], $ row ['SJ _ date']);

Text formatting:{$ Cat_goods.name | escape: html}

String truncation:{$ Brand. brand_desc | truncate: 11}, {$ article. short_title | truncate: 15: "...": true}

Handling Line breaks:{$ Title | nl2br} changes the line break in php to HTML

Filter HTML tags:{$ Title | strip_tags}

Goods. dwt big image:{$ Pictures.0.img _ url}

[Secondary development of background templates]

1. add product attributes:

A. add the field (sj_date) to the data table (* _ goods ).

B. add to the template (admin/templates/goods_info.htm)

C. submit the data processing function to the background to add fields to the database (admin/goods. php ).

D. The frontend display function is used for processing (using des \ lib_goods.php ).

2. set the background template [product category page template] to add new product shelving:

A. add a record to the data table (* _ template)

B. add a new library to/admin/mongodes/lib_template.php (3 indicates the editable quantity)

3. Traverse multi-dimensional arrays in the template:

A. array prototype: print_r print

$ Smarty-> assign ('properties', $ properties ['pro']); // product property print_r ($ properties ['pro']); => Array ([technical parameters] => Array ([1] => Array ([name] => connection [value] => 3.5/6.3) [2] => Array ([name] => wear mode [value] => Head Mounted) [3] => Array ([name] => Feature [value] => Active Noise Reduction )))View Code

B. Template foreach traversal

  • {$ Arr2.name }:
  • View Code

    Secondary development of message board:

    Completed functions:

    1. \ shortdes \ inc_constant.php line: 129 add define ('m _ short', 7); // for sale

    2. \ ages \ zh_cn \ common. php line: 634 add $ _ LANG ['message _ type'] [m_sale] = 'sale ';

    3. \ ages \ zh_cn \ admin \ user_msg.php line: 35 modify $ _ LANG ['type'] = array ('login', 'Complaint ', 'query', 'aftersales ', 'purchase ', 'Merchant message', 'Comments', 'sale '); // note the subscript.

    4. Data Table (*_feedback) Add fields

    5./message. php line: 72 $ receive data transmitted on the page in the message array

    6./includes/lib_clips.php line: 197 $ add a field to the database in SQL

    7. the msg_info.htm template is displayed in the background.

    • Product Name:{$ Msg. msg_title | escape: "html "}
    • Product model:{$ Msg. goods_type | escape: "html "}
    • Sale price:{$ Msg. goods_price}
    • Name:{$ Msg. user_name}
    • Email:{$ Msg. user_email}
    • Document type:{If $ msg. papers_type = 0} ID card {elseif $ msg. papers_type = 1} passport {elseif $ msg. papers_type = 2} driver's license {else} Taiwan compatriot permit {/if}
    • ID No:{$ Msg. paper_number}
    • Tel:{$ Msg. tel}
    • Address:{$ Msg. address}
    • Note:{$ Msg. msg_content | escape: "html" | nl2br}

    View Code

    Compile (1), ecshop secondary development note \ mongodes \ lib_commom.php = public function library \ mongodes \ lib_main.php = front-end public function library \ mongodes \ lib_init.php = initialization,...

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.