ECMall request and system jump _ PHP Tutorial

Source: Internet
Author: User
ECMall requests and system redirects. Ecmall is a framework system based on the mvc mode, which is a bit like thinkphp. Starting from the ecmall entry point, the ecmall entry file uploadindex. php, admin. php: index. php starts the ecmall front-end. starting ecmall is a mvc-based framework system, which is a bit like thinkphp. Starting from the ecmall entry, the ecmall entry file upload/index. php and admin. php:

Index. php starts the ecmall front-end, and then enters the ecmall framework core file ecmall. php. ecmall. php is equivalent to a scheduling center. it receives different control commands (apps) and command-related operations (funciton), and then allocates them for processing. The scheduling center then uploads these commands and functions to the specific controller corresponding to the foreground control center. After the "controller" receives the command, it implements the execution control and sends the processed result to the view template file (the template naming rule is appname.fucname.html ).

When the controller receives the command execution, it can call the model acquisition method of the scheduling Center & m () to instantiate a model and perform the data curd operation.

Index. php:

Include (ROOT_PATH. '/eccore/ecmall. php ');/* start ECMall */ECMall: startup (array ('default _ app' => 'default', 'default _ AC' => 'index ', 'app _ root' => ROOT_PATH. '/app', // The basic class required for loading the system 'external _ Libs' => array (ROOT_PATH. '/regiondes/global. lib. php', ROOT_PATH. '/regiondes/libraries/time. lib. php', ROOT_PATH. '/shortdes/ecapp. base. php', ROOT_PATH. '/uplodes/plugin. base. php', ROOT_PATH. '/app/frontend. base. php ',),));

Ecmall. php:

Class ECMall {/* start */function startup ($ config = array () {/* load the initialization file */require (ROOT_PATH. '/eccore/controller/app. base. php '); // basic controller class require (ROOT_PATH. '/eccore/model. base. php '); // model base class if (! Emptyempty ($ config ['external _ Libs']) {foreach ($ config ['external _ Libs'] as $ lib) {require ($ lib );}} /* data filtering */if (! Get_magic_quotes_gpc () {$ _ GET = addslashes_deep ($ _ GET); $ _ POST = addslashes_deep ($ _ POST); $ _ COOKIE = addslashes_deep ($ _ COOKIE );} /* request forwarding */$ default_app = $ config ['default _ app']? $ Config ['default _ app']: 'default'; $ default_act = $ config ['default _ AC']? $ Config ['default _ act ']: 'index'; $ app = isset ($ _ REQUEST ['app'])? Trim ($ _ REQUEST ['app']): $ default_app; $ act = isset ($ _ REQUEST ['AC'])? Trim ($ _ REQUEST ['AC']): $ default_act; $ app_file = $ config ['app _ root']. "/{$ app }. app. php "; if (! Is_file ($ app_file) {exit ('missing controller');} require ($ app_file); define ('app', $ APP); define ('AC ', $ act); $ app_class_name = ucfirst ($ app ). 'app';/* instantiate the controller */$ App = new $ app_class_name (); c ($ app); $ app-> do_action ($ act ); // forward the file to the corresponding Action $ app-> destruct () ;}// determine whether to load the corresponding controller file based on the parameters following the app, the class file is in the app folder, and the corresponding name is the same as the parameter. the parameter after act is the action corresponding to the operation method in the controller to process the request // and there is a judgment in the action: if (! IS_POST) {display of the page content before the request} else {form processing after the request and page jump after the processing is complete }. Which includes processing data in json format. // Here, we need to propose: $ this-> assign ('order', $ order_info) in the controller ); // pass the value of the required parameter to the template page $ this-> display('buyer_order.confirm.html '); // the page to jump to $ this-> json_result ($ new_data, 'confirm _ order_successed '); // use json to pass parameters, and then use javascript to process request redirects on the page

Because of this mechanism, you can add apps, modules, and plug-ins to ECMALL. How can I add my own APP to ECMALL? For example, the access address is http://xxx.com/index.php? App = hello

  1. Create an application file named hello. app. php in the app directory of ecmall.
  2. Create the corresponding language file hello. lang. php in the sc-utf8 directory of ages and return the array (if not set up, an error will occur)
  3. The class in hello. app. php is HelloApp and inherits the FrontendApp
  4. This is a front-end program. a hello.index.html template file is created under the themes/mall/defaultfolder of ecmall.
  5. Override the default index method and use the template to output the result:
  6. $h = "Hello";      $this->assign("h",$h);      $this->display('hello.index.html');  
  7. Write other methods such as the access address is http://xxx.com/index.php? App = hello & act = test

This URL accesses the test method in the app class named hello, actually http://xxx.com/index.php? App = hello the index method is accessed by default.

// 1. create a test. app. php file under upload/app /.
 '; $ Uc_words = ucwords ($ str ).'
'; $ Model = & m ('Goods'); $ res = $ Model-> get (27); print_r ($ res ); $ this-> assign ('SS', $ uc_first); $ this-> assign ('SS', $ uc_words); $ this-> display('test.index.html ') ;}}?> // 2. create a test. lang. php under upload/languages/sc-utf-8/ // 3. create a test.index.html file in upload/themes/mall/default /.

Admin. php this is to start the ecmall background. After it is started, enter the core file ecmall. php of the ecmall framework. The subsequent operations are similar to those at the front-end. The difference is that the scheduling center sends commands to the "back-end" control center. However, the model called by the controller is the same model Center.

Bytes. Starting from the ecmall entry, start the ecmall entry file upload/index. php and admin. php: index. php to start the ecmall front-end and start...

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.