Home > CMS Tutorial > ECShop > ECSHOP introduces secondary development techniques

ECSHOP introduces secondary development techniques

coldplay.xixi
Release: 2021-03-10 10:56:48
forward
2445 people have browsed it

ECSHOP introduces secondary development techniques

Foreword: ECSHOP is a complete online store solution, including front-end product display, shopping process and powerful and easy-to-use back-end management. Because ecshop is simple and easy to use, users can almost have an online store system with a simple setup in 3 minutes. Therefore, many B2C sites have chosen to use the ECShop online store system, but sometimes we need to do something that ecshop does not have. function or front-end display, at this time we need to carry out secondary development of ecshop ourselves.

Recommended (free): ecshop

# #1. Secondary development of ecshop system functions

##The code structure of ecshop is very easy to understand. As long as you have a little PHP basics, you can modify it on the basis of the original program or function. Plug-in development.

Some public functions in ecshop will be placed in the includes folder, and almost all of these public functions can be used as a reference to easily create other functions we want. .

We need to carry out secondary development of ecshop. To put it simply, it is actually reading and writing operations on the database. So as long as we understand the database operation class of ecshop, the next implementation is very simple. Relaxed.

ecshop's database operation class is very powerful. Some commonly used functions are as follows:

1. Get a single record

$GLOBALS['db']->getRow($sql);
Copy after login


##2. Get a single field

$GLOBALS['db']->getOne($sql);
Copy after login


For example, query the total number of products:

echo $GLOBALS['db']->getOne(‘SELECT COUNT(*) FROM ‘ . $GLOBALS['ecs']->table(‘goods’) ;
Copy after login

##3. Get all records

$GLOBALS['db']->getAll($sql);
Copy after login

4. Execute sql statement

$GLOBALS['db']->query($sql);
//执行删除(DELETE),插入(INSERT),更新(UPDATE)等操作可用此方法
Copy after login

5. Insert array elements into the database

$parent['goods_number'] = ’1′;
$parent['parent_id'] = 0;
$GLOBALS['db']->autoExecute($GLOBALS['ecs']->table(‘cart’), $parent, ‘INSERT’);
Copy after login

#On this basis, you can easily carry out secondary development of ecshop.

2. Secondary development of ecshop front-end template

ecshop has a powerful template mechanism, which is implemented by ECSHOP combined with Dreamweaver It has a template mechanism. Changing the template no longer requires uploading, but can be done with a little effort in the background.

ecshop uses smarty template technology. Smarty is a template engine written in PHP and is currently one of the most famous PHP template engines in the industry. It separates logical code and external content, providing an easy-to-manage and use method to separate PHP code logic that is originally mixed with HTML code.

Use the assign method in the php file to pass the php variable value to the template file, for example:

$smarty->assign(‘action’, $action);
//把php中的变量$action传值给模板文件(*.dwt)中的’action’变量,模板文件可用{$action}来输出此值。
Copy after login

Use the display method to specify the current template file and output to the file to display to the client, for example:

$smarty->display(‘user_passport.dwt’);
Copy after login

More Free learning recommendation:

ecshop tutorial

The above is the detailed content of ECSHOP introduces secondary development techniques. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template