显示ZenCart模版内容的流程
显示ZenCart模版内容的流程, require(‘includes/application_top.php’);初始化所有需要用到的公共信息以后,接下来就应该是显示了在index.php的第29行有句 $directory_array = $template->get_template_part($code_page_directory, ‘/^header_php/’);由于所有初始化工作已经完成,所以我们就可以在上面的文件找到他们的定义,如 $autoLoadConfig[100][] = array(‘autoType’=>’classInstantiate’,’className’=>’template_func’,’objectName’=>’template’);在这里就定义了$template = new template_func(); ,然后$code_page_directory变量的定义是在init_includes/init_sanitize.php文件中定义在这里必须要对class/template_func.php中定义的template_func类比较熟悉,在该类中主要定义了两个方法get_template_dir()和get_template_part();这两个方法在zencart的模版中起到了决定性的作用我简单的说下get_template_dir方法function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false),它定义了5个参数,第一个参数一般是个文件名,它是用来判断后两个参数组成的目录中有没有匹配$template_code的这个文件,该类复写了默认的系统函数file_exists所以很多初学者可能会比较迷惑function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false) { if ($this->file_exists($current_template .…