Ecshop secondary development structure analysis and code Research

Source: Internet
Author: User

Introduction: THIS IS THE STRUCTURE ANALYSIS ANDCodeOn the details page of the study, I introduced the related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 325743 'rolling = 'no'>

Ecshop includes admin, API, cert, Data, images, Des, JS, ages, plugins, temp, theme, WAP, widgets, and all the folders in the root directory. PHP file. These files and folders constitute the entire ecshop. If you analyze ecshop from the perspective of software engineering, the level 2 of ecshop can be regarded as admin and foreground. Admin is mainly for the server, while the front-end is for the client, which is the most obvious difference between the two parts. The second-level flow chart of ecshop is given below:

The second-level flowchart shows the relationship between the admin module, the foreground display module, and the database module. As shown in the preceding figure, the admin module reads and writes the database. The read and write operations constitute the entire background management, this includes product addition and deletion, Message Management, and order processing. The front-end module also needs to read and write the database. Its read and write mainly completes the transaction process, the content is basically the number that must be changed in the commodity transaction with the number of commodities and the number of clicks. In the admin module, you can also write the display on the foreground. This write process mainly changes the display mode on the foreground. For example, you can select a template for the admin module; you can also change whether or not each small module is displayed on a page and its position (if displayed ).

Images Folder:

This folder contains subfolders that store the original images and thumbnails of the current website product. These subfolders are named regularly, and their file names are the year and month of the products under their directories. That is to say, the products added in the same month are in the same folder, and the folder name is the current year month. Each time you add a product with an image in the background, a copy of the submitted image appears in a folder.

Data Folder:

This folder contains some fixed data, such as fixed configurations and images. Config. php In the data folder records some fixed information about the database. The afficheimg folder stores the flash image source in the middle of the home page. To load images in the afficheimg folder to the flash of the home page, you can use the Javascript in the dynfocus folder under the flashdata folder. The brandlogo folder stores the company logo of the brand product, and the background image of the verification code under the CAPTCHA folder.

Theme Folder:

The theme folder is solely responsible for display on the page. How is the prepared data displayed in. DWT under theme? Data is loaded through smarty. In the root directory. there will be sentences like $ smarty-> assign ('page _ title', $ position ['title']) in the PHP file, in this way, page_title can be used as a variable in the corresponding DWT file. In this way, the PHP file is well integrated with the DWT file.

Next, let's talk about the DWT file. Most of the information in this file is automatically generated. This block is displayed in the DWT file. It is used to determine the position of each module. If a module is displayed in the left area in the background ", the code of this module is generated in the above area. Of course, in the DWT file, we will also see that all the code here is automatically generated. You can only change this. LBI file. In addition, you cannot directly edit the code between the two logos before they appear. To add your own code, you must insert it before the next ininlibraryitem.

Program:

The program mainly includes all the PHP scripts, Des, and JS folders under the root directory (which is about the front-end). These scripts are used to prepare the data displayed on the front-end. Therefore, they play an important role in the entire ecshop structure, and the modifications to ecshop are mainly concentrated in these scripts. The specific analysis of these scripts will be given in the later stages.

In the previous article, we introduced the overall ecshop framework. From the perspective of ecshop, I believe everyone's ideas should be clear. As a modifier for open-source projects, you can have a preliminary understanding of ecshop. Below I will give you some experience in the process of modifying ecshop.

Remember to talk about Adobe templates in the previous article. Next we will discuss the template with you based on ecshop. When it comes to templates, this is the main file displayed on the ecshop front-end. If you can understand the template files and style sheet files under theme well, there should be no problems with the front-end display of ecshop. How is the page displayed in ecshop? We put this problem aside first. We will first study how ecshop reads a series of data from the database and then transfer it to the display page. To solve this problem, use index. php In the root directory and index. DWT in theme/default as the use case. The corresponding two folders are used because the data to be displayed in index. DWT is loaded from index. php using smarty. The following code is available in index. php:

 
$ Position = assign_ur_here (); $ smarty-> assign ('page _ title', $ position ['title']); // page title $ smarty-> assign ('ur _ here ', $ position ['ur _ here']); // The current position

First, it calls the assign_ur_here function. In this way, the variable $ position is obtained. In the variable $ position, there are two variables: Title and ur_here. The following code is available in index. DWT:

<Title >{$ page_title} <title>

Yes. Once $ smarty-> assign ('page _ title', $ position ['title']) is executed, $ page_title will be in index. in dwt, it becomes a usable variable. So far we know how to transmit the required variables to the DWT file from the PHP script. Smarty transfers the content to be displayed to the corresponding DWT file through this mechanism, thus realizing the separation of pages and content. The data in the PHP script can be obtained in the DWT file. The following describes how to display the data. All variables loaded to the DWT file through smarty are displayed. If an array is loaded, it will be displayed through the smarty loop. If an array is $ School and each entry of the array contains name, the following code displays the name of each entry of the array on the page.

 
Foreach ($ school as $ K) {echo $ K ['name']. '';}

In this way, all the contents of the array will be printed out on the page.

The following is an example of how the DWT is displayed.

Write smarty-> assign ('test', 'this is just a test! ');

Write {$ test} somewhere in index. dwt, and then "this is a test!" will appear on the homepage !". Of course, it is related to where you put {$ test. Of course, this location is specified. Not all parts of the DWT can be edited, but some parts cannot be edited. We will explain these parts one by one later. At this time, if "this is a test!" is not displayed on your homepage !" Don't worry about this content, because the default cache in ecshop is on, and it cannot be displayed. This will be explained later. Today, we will discuss how to display parameters and parameters in DWT. Next time, thanks will explain the remaining issues.

Hello everyone, today we are here to solve the problems left over from the last one. The last time we talked about how to transmit parameters from the PHP script to the DWT template, we also left two questions: first, some parts of the DWT cannot be edited; the second is to pass parameters to the DWT and display them. It is not necessarily displayed.

First, let's discuss the first question: why is there something that cannot be edited. We will discuss index. DWT to analyze the cause of this problem. In index. dwt, we can see many

Such a statement. If you are familiar with the background management of ecshop, you should be familiar with the words "area on the left! Yes, you will see the following picture in the background template Management> Settings template.

On the surface, everyone should know that, for example, the "product category Tree" is displayed in the middle of the entire page. So why are you sure you want to display it on the page based on your choice? In essence, each of the above modules corresponds to a library file (the LBI file in the library under theme ), after you set the above settings according to your layout, click OK. The program will write the content of each LBI file to the index according to your layout selection. in dwt, where should the content in the LBI file be written?

This sentence plays a role. For example, if the "sales ranking" above is the right area of the selection, then after you confirm, the program will index. the content in the LBI (top10.lbi) corresponding to the "sales ranking" is fully read and written to the index. in dwt. At this time, you may have a question: if there is a lot of content to be written to the right area, which one should be written first? In the figure above, there is a "Serial Number", which determines the write order. Below is a piece of code between the written index. DWT file and the file:

<Div class = "box"> <Div class = "box_2"> <Div class = "top10tit"> div> <Div class = "top10list"> <ul> <li>  <a Title =" {$ goods. name | escape: HTML} "href =" {$ goods. URL} "> {$ goods. short_name} A> LI> ul> div> <Div class = "blank5"> div>

Okay, I believe you should know a lot here, so why is there something in index. DWT that cannot be edited. Let's think about where the above Code comes from, right, it is read from top10.lbi, and then written here. If you edit it, and then re-layout it next time, the content here is not to be rewritten! Therefore, in index. dwt, the content similar to and between is dynamically generated and cannot be edited. If you really want to edit the content here, You can edit the corresponding LBI file.

I believe you know why part of the DWT file cannot be edited. Let's talk about this today. Next time we will study the cache issue. I think this is a headache (if you add a session yourself ).

Last time, we mainly discussed the issue about the template. Finally, we left a question: cache. I don't think we should discuss this issue until now. Let's try again later. Now we know some template operations, but we are still very depressed, because we are only under the control of the front-end framework of ecshop. So how can we get rid of it? If we can add a template that belongs to ourselves or can store the things we want, we should be able to look at ecshop at a higher level.

To add a template, you must display the template on the foreground and edit the template on the background. Next, we will teach you how to add a template of your own. Before adding a template, let's analyze it a little. For a template, there must be a PHP file at the front end that corresponds to it (obviously this PHP file is used to transfer data to this template file ). In addition, you can edit the template module in the background, that is, in template management-set the template options you have added. Next we will add a home template. First, create home. DWT and home. php In the root directory. Copy the content in index. DWT and index. php to home. DWT and home. php respectively. The content of this template is completely determined by yourself. Your content will decide how you want to modify home. DWT and home. php. Of course, the content of this template is restricted. First, the candidate library file of this template must exist. What does this mean? The meaning of this sentence is that for each template file, the library files that can be called are fixed, and these library files that can be called are defined in the file admin/mongodes/lib_templete.php. First, you need to add the home template to the template with configurable content in the background. Some code is as follows:

 
/* Content template */$ template_files = array ('home. DWT ', 'index. DWT ', 'zhiku. DWT ', 'Article. DWT ', 'Article _ cat. DWT ', 'brand. DWT ', 'category. DWT ', 'user _ clips. DWT ', 'compare. DWT ', 'gallery. DWT ',

in the above Code, add home. DWT to the Editable template in the background. At this time, you can edit the home template in the background template Management> Settings template. But here we find a very small problem, that is, the name of the home template displayed in the background. In fact, this is very simple, as long as the file language/zh_cn/admin/template. add $ _ Lang ['template _ files'] ['home'] = 'home template' in PHP, the name of the home template displayed in the background is "home template". You can also set it to another name here. As we have mentioned above, the library files that can be called by each template are fixed. Since they are fixed, what should they be? Take the index for example. The following code is available in the file admin/cmddes/lib_templete.php:

'Index' => array ('/library/ur_here.lbi' => 0, '/library/search_form.lbi' => 0, '/library/member. LBI '=> 0,'/library/new_articles.lbi '=> 0,'/library/success_article.lbi '=> 0,'/library/dynamic_article.lbi '=> 0, '/library/school_article.lbi' => 0, '/library/category_tree.lbi' => 0, '/library/top10.lbi' => 0, '/library/invoice_query.lbi' => 0, '/library/recommend_best.lbi' => 3, '/library/recommend_new.lbi' => 3, '/library/recommend_hot.lbi' => 3, '/library/comment' => 4, '/library/group_buy.lbi' => 3, '/library/auction. LBI '=> 3,'/library/brands. LBI '=> 0,'/library/promotion_info.lbi '=> 0,'/library/cart. LBI '=> 0,'/library/order_query.lbi '=> 0,'/library/email_list.lbi '=> 0,'/library/vote_list.lbi '=> 0 ),

The enumerated library files can be called for index. dwt. Which library files need to be called by the home. DWT File Based on Huludao? The above write is correct. I believe everyone has this level. Okay. So far, a template file has been added successfully, so it will be determined by setting the template in the background for display in the browser. Okay. I will talk about adding a template of my own. We will continue to discuss ecshop in the next period. Thanks !!!

More articles on "ecshop secondary development structure analysis and code research"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/325743.html pageno: 13.

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.