zencart的运行流程

      在国内有很多的外贸电子商务网站中有很多公司选择了zencart平台,这是一款开源的开发平台,对于zencart的初学者来说.想要搞明白zencart的运行流程不是一件很简单的事情.那这里我将我自己学习zencart的心得与大家一起分享,希望对初学者们有所帮助^_^

要想搞明白zencart的运行流程,就必须对根目录下的index.php文件有相当的了解.

下面我们来看一下index.php文件

(1)require('includes/application_top.php');

该文件定义了一系列的常量(共用的)。

(2)$language_page_directory= DIR_WS_LANGUAGES . $_SESSION['language'] . '/';

该文件定义了一系列的常量(具体页面所特有的常量)

(3)$directory_array= $template->get_template_part($code_page_directory,'/^header_php/');

加载目录文件下所有的header_php.php文件,该文件相当于控制器可以在其中做些与数据库相关的操作.

(4)require($template->get_template_dir('html_header.php',DIR_WS_TEMPLATE,$current_page_base,'common'). '/html_header.php');

get_template_dir()这个方法一定要认真的看,因为这个文件涉及到html_header.php的重写,html_header.php主要显示的是视图文件中的<head></head>部分.

下面是html_header.php的优先级.

优先级有高到低的次序是

includes/templates/classic/*/html_header.php
includes/templates/template_default/*/html_header.php
includes/templates/classic/common/html_header.php
includes/templates/template_default/common/html_header.php

*表示你所显示页面的名称

(5)require($template->get_template_dir('main_template_vars.php',DIR_WS_TEMPLATE,$current_page_base,'common'). '/main_template_vars.php');

html_header.php的加载方法类似.main_template_vars.php决定了要加载的网页的主体内容.  

优先级由高到低的次序是

includes/templates/classic/news_list/main_template_vars.php
includes/templates/template_default/news_list/main_template_vars.php
includes/templates/classic/common/main_template_vars.php
includes/templates/template_default/common/main_template_vars.php

(6)

on_load_*.js文件中包含了要在<body>标记的onload属性中出现的内容, 即在页面加载完成后要执行的脚本. 可以在同一个页面中定义多个on_load_*.js文件, 这些内容将会同时被执行.

on_load_*.js文件可能是页面级和站点级的. 页面级的on_load_*.js文件只在当前页面中有效, 而站点级on_load_*.js文件将对站点中的每个页面有效. 有关如何定义页面级和站点级的onload事件, 将在后面的章节予以描述.

在这里, 页面级和站点级的on_load_*.js文件内容都将读入$za_onload_array[]数组中, 然后组合到变量$zv_onload中, 为后面做好准备. $zv_onload最终将作为到<body>的onload属性值.  

(7)

这里定义将选择影响页面布局的模板, 可以在具体的页面中选择, 或者使用zen-cart默认的模板(一个标准的三列板式), 模板中会对main_template_vars.php中定义的变量$body_code所指文件予以加载.

(8)加载application_bottom.php文件

application_bottom.php文件中将进行一些清理操作.




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章