{"id":60967,"date":"2025-04-26T08:55:44","date_gmt":"2025-04-26T00:55:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60967\/"},"modified":"2025-04-26T08:55:44","modified_gmt":"2025-04-26T00:55:44","slug":"%e6%98%be%e7%a4%bazencart%e6%a8%a1%e7%89%88%e5%86%85%e5%ae%b9%e7%9a%84%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60967\/","title":{"rendered":"\u663e\u793aZenCart\u6a21\u7248\u5185\u5bb9\u7684\u6d41\u7a0b"},"content":{"rendered":"<p>\u663e\u793aZenCart\u6a21\u7248\u5185\u5bb9\u7684\u6d41\u7a0b,<br \/>\n<br \/> require(&#8216;includes\/application_top.php&#8217;);\u521d\u59cb\u5316\u6240\u6709\u9700\u8981\u7528\u5230\u7684\u516c\u5171\u4fe1\u606f\u4ee5\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u5e94\u8be5\u662f\u663e\u793a\u4e86\u5728index.php\u7684\u7b2c29\u884c\u6709\u53e5<br \/>\n<br \/> $directory_array = $template-&gt;get_template_part($code_page_directory, &#8216;\/^header_php\/&#8217;);\u7531\u4e8e\u6240\u6709\u521d\u59cb\u5316\u5de5\u4f5c\u5df2\u7ecf\u5b8c\u6210\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u6587\u4ef6\u627e\u5230\u4ed6\u4eec\u7684\u5b9a\u4e49,\u5982 $autoLoadConfig[100][] = array(&#8216;autoType&#8217;=&gt;&#8217;classInstantiate&#8217;,&#8217;className&#8217;=&gt;&#8217;template_func&#8217;,&#8217;objectName&#8217;=&gt;&#8217;template&#8217;);\u5728\u8fd9\u91cc\u5c31\u5b9a\u4e49\u4e86$template = new template_func(); ,\u7136\u540e$code_page_directory\u53d8\u91cf\u7684\u5b9a\u4e49\u662f\u5728init_includes\/init_sanitize.php\u6587\u4ef6\u4e2d\u5b9a\u4e49\u5728\u8fd9\u91cc\u5fc5\u987b\u8981\u5bf9class\/template_func.php\u4e2d\u5b9a\u4e49\u7684template_func\u7c7b\u6bd4\u8f83\u719f\u6089\uff0c\u5728\u8be5\u7c7b\u4e2d\u4e3b\u8981\u5b9a\u4e49\u4e86\u4e24\u4e2a\u65b9\u6cd5get_template_dir()\u548cget_template_part();\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u5728zencart\u7684\u6a21\u7248\u4e2d\u8d77\u5230\u4e86\u51b3\u5b9a\u6027\u7684\u4f5c\u7528\u6211\u7b80\u5355\u7684\u8bf4\u4e0bget_template_dir\u65b9\u6cd5function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false),\u5b83\u5b9a\u4e49\u4e865\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e00\u822c\u662f\u4e2a\u6587\u4ef6\u540d,\u5b83\u662f\u7528\u6765\u5224\u65ad\u540e\u4e24\u4e2a\u53c2\u6570\u7ec4\u6210\u7684\u76ee\u5f55\u4e2d\u6709\u6ca1\u6709\u5339\u914d$template_code\u7684\u8fd9\u4e2a\u6587\u4ef6,\u8be5\u7c7b\u590d\u5199\u4e86\u9ed8\u8ba4\u7684\u7cfb\u7edf\u51fd\u6570file_exists\u6240\u4ee5\u5f88\u591a\u521d\u5b66\u8005\u53ef\u80fd\u4f1a\u6bd4\u8f83\u8ff7\u60d1function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false) {&nbsp; &nbsp; if ($this-&gt;file_exists($current_template . $current_page, $template_code)) {&nbsp; &nbsp; &nbsp; return $current_template . $current_page . &#8216;\/&#8217;;&nbsp; &nbsp; } elseif ($this-&gt;file_exists(DIR_WS_TEMPLATES . &#8216;template_default\/&#8217; . $current_page, ereg_replace(&#8216;\/&#8217;, &#8221;, $template_code), $debug)) {&nbsp; &nbsp; &nbsp; return DIR_WS_TEMPLATES . &#8216;template_default\/&#8217; . $current_page;&nbsp; &nbsp; } elseif ($this-&gt;file_exists($current_template . $template_dir, ereg_replace(&#8216;\/&#8217;, &#8221;, $template_code), $debug)) {&nbsp; &nbsp; &nbsp; return $current_template . $template_dir;&nbsp; &nbsp; } else {&nbsp; &nbsp; &nbsp; return DIR_WS_TEMPLATES . &#8216;template_default\/&#8217; . $template_dir;&nbsp; &nbsp; }}<br \/>\n<br \/> get_template_part()\u65b9\u6cd5\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u6587\u4ef6\u76ee\u5f55\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u5339\u914d\u7684\u6761\u4ef6\uff0c\u6267\u884c\u7684\u7ed3\u679c\u662f\u5305\u542b\u8be5\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u540d\u5339\u914d\u8fd9\u4e2a\u6761\u4ef6\u7684\u6587\u4ef6\u6bd4\u5982$directory_array = $template-&gt;get_template_part($code_page_directory, &#8216;\/^header_php\/&#8217;);\u8fd9\u53e5\u8bdd\u6267\u884c\u7684\u7ed3\u679c\u5c31\u662f\u8fd4\u56de\u76ee\u5f55\u4e0b$code_page_directory\u6240\u6709\u6587\u4ef6\u540d\u4ee5header_php\u5f00\u5934\u7684\u6587\u4ef6\u5982\u6b64\u65f6\u7684url(http:\/\/localhost\/zencart\/index.php?main_page=product_info&amp;cPath=49_27&amp;products_id=83)\u4f60\u73b0\u5728\u5e94\u8be5\u67e5\u770binit_sanitize.php\u4e2d$code_page_directory\u7684\u5b9a\u4e49\u6b64\u65f6\u7684$code_page_directory\u7684\u503c\u5e94\u8be5\u662fincludes\/modules\/product_info\/\u6240\u4ee5\u5b83\u5c31\u5e94\u8be5\u5305\u542b\u8be5\u76ee\u5f55\u4e0b\u6240\u6709\u4ee5header_php\u5f00\u5934\u7684\u6587\u4ef6,\u5728\u8fd9\u91cc\u597d\u8c61\u5c31\u53ea\u6709\u4e00\u4e2aheader_php.php<br \/>\n<br \/> $directory_array = $template-&gt;get_template_part($code_page_directory, &#8216;\/^header_php\/&#8217;);\u8fd9\u4e2a\u5305\u542b\u6587\u4ef6\u5176\u5b9e\u662f\u521d\u59cb\u5316\u524d\u53f0\u4e0d\u540c\u9875\u9762\u663e\u793a\u6240\u9700\u8981\u7528\u5230\u7684\u53d8\u91cf\u51fd\u6570\uff0c\u4e3b\u8981\u662f\u521d\u59cb\u5316\u6570\u636e\u5e93\u7684\u4e1c\u897f,\u56e0\u4e3a\u6bcf\u4e2a\u9875\u9762\u9700\u8981\u7684\u6570\u636e\u8d44\u6599\u90fd\u6709\u53ef\u80fd\u4e0d\u540c,\u6240\u4ee5index.php?main_page=index \u5f53main_page\u7684\u503c\u4e0d\u540c\u662f\u5728includes\/modules\/\u76ee\u5f55\u4e0b\u90fd\u4f1a\u6709\u4e2a\u5bf9\u5e94\u7684\u76ee\u5f55\uff0c\u8fd9\u91cc\u662findex\u76ee\u5f55<\/p>\n<p> \u53ea\u8981\u77e5\u9053\u4e86\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u7684\u7528\u6cd5\uff0c\u4f60\u5c31\u4f1a\u77e5\u9053\u6a21\u677f\u6587\u4ef6\u90fd\u662f\u600e\u4e48\u663e\u793a\u51fa\u6765\u7684\u4e86<\/p>\n<p> \u518d\u6765\u89e3\u91ca\u4e00\u4e0b require($template-&gt;get_template_dir(&#8216;html_header.php&#8217;,DIR_WS_TEMPLATE, $current_page_base,&#8217;common&#8217;). &#8216;\/html_header.php&#8217;);\u5047\u8bbe\u5f53\u524durl:http:\/\/localhost\/zencart\/index.php?main_page=index&amp;cPath=48DIR_WS_TEMPLATE \u5b9a\u4e49\u662f\u5728includes\/init_templates.php\u4e2d\u5b9a\u4e49define(&#8216;DIR_WS_TEMPLATE&#8217;, DIR_WS_TEMPLATES . $template_dir . &#8216;\/&#8217;);,\u56e0\u4e3a\u6211\u73b0\u5728\u7528\u7684\u662f\u9ed8\u8ba4\u7684zccn\u6a21\u677f\u6240\u4ee5\u73b0\u5728\u7684DIR_WS_TEMPLATE=includes\/templates\/zccn\/$current_page_base\u5728\u8fd9\u91cc\u5df2\u7ecf\u5c31\u662findex\u4e0a\u9762\u5df2\u7ecf\u89e3\u91ca\u4e86$template-&gt;get_template_dir()\u7684\u65b9\u6cd5\u4e86\u7a0b\u5e8f\u4f1a\u4f9d\u6b21\u5728includes\/templates\/zccn\/indexincludes\/templates\/template_default\/indexincludes\/templates\/zccn\/commonincludes\/templates\/template_default\/common\u8fd9\u56db\u4e2a\u76ee\u5f55\u4e0b\u627ehtml_header.php\uff0c\u5728\u8fd9\u91cc\uff0c\u6700\u7ec8\u5728template_defaultcommon\u76ee\u5f55\u4e0b\u627e\u5230html_header.php<br \/>\n<br \/> \u5230\u8fd9\u91cc\u5c31\u53ef\u4ee5\u81ea\u5df1\u5199\u6a21\u677f\u6587\u4ef6\u4e86,\u56e0\u4e3a$template-&gt;get_template_dir()\u662f\u6309\u987a\u5e8f\u627e\u7684\uff0c\u6240\u4ee5\u4f60\u53ea\u8981\u5728\u4f60\u7684\u6a21\u677f\u6587\u4ef6\u4e2d\u5b58\u5728\u8be5\u6587\u4ef6\u5373\u53ef.<br \/>\n<br \/> ===================================================================<br \/>\n<br \/> \/includes\/modules\/pages\/\u6a21\u5757\u540d\/header_php.php (\u6a21\u5757\u4e1a\u52a1\u903b\u8f91\u7a0b\u5e8f\u6587\u4ef6)<br \/>\n<br \/> \/includes\/modules\/pages\/\u6a21\u5757\u540d\/jscript_main.php (\u6a21\u5757JS\u7a0b\u5e8f\u6587\u4ef6)<br \/>\n<br \/> \/includes\/templates\/\u6a21\u5757\u540d\/templates\/tpl_\u6a21\u5757\u540d_default.php (\u6a21\u5757\u5bf9\u5e94\u7684\u6a21\u677f\u6587\u4ef6)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u663e\u793aZenCart\u6a21\u7248\u5185\u5bb9\u7684\u6d41\u7a0b, require(&#8216;includes\/application_top.php&#8217;);\u521d\u59cb\u5316\u6240\u6709\u9700\u8981\u7528\u5230\u7684\u516c\u5171\u4fe1\u606f\u4ee5\u540e\uff0c\u63a5\u4e0b\u6765\u5c31\u5e94\u8be5\u662f\u663e\u793a\u4e86\u5728index.php\u7684\u7b2c29\u884c\u6709\u53e5 $directory_array = $template-&gt;get_template_part($code_page_directory, &#8216;\/^header_php\/&#8217;);\u7531\u4e8e\u6240\u6709\u521d\u59cb\u5316\u5de5\u4f5c\u5df2\u7ecf\u5b8c\u6210\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u4e0a\u9762\u7684\u6587\u4ef6\u627e\u5230\u4ed6\u4eec\u7684\u5b9a\u4e49,\u5982 $autoLoadConfig[100][] = array(&#8216;autoType&#8217;=&gt;&#8217;classInstantiate&#8217;,&#8217;className&#8217;=&gt;&#8217;template_func&#8217;,&#8217;objectName&#8217;=&gt;&#8217;template&#8217;);\u5728\u8fd9\u91cc\u5c31\u5b9a\u4e49\u4e86$template = new template_func(); ,\u7136\u540e$code_page_directory\u53d8\u91cf\u7684\u5b9a\u4e49\u662f\u5728init_includes\/init_sanitize.php\u6587\u4ef6\u4e2d\u5b9a\u4e49\u5728\u8fd9\u91cc\u5fc5\u987b\u8981\u5bf9class\/template_func.php\u4e2d\u5b9a\u4e49\u7684template_func\u7c7b\u6bd4\u8f83\u719f\u6089\uff0c\u5728\u8be5\u7c7b\u4e2d\u4e3b\u8981\u5b9a\u4e49\u4e86\u4e24\u4e2a\u65b9\u6cd5get_template_dir()\u548cget_template_part();\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u5728zencart\u7684\u6a21\u7248\u4e2d\u8d77\u5230\u4e86\u51b3\u5b9a\u6027\u7684\u4f5c\u7528\u6211\u7b80\u5355\u7684\u8bf4\u4e0bget_template_dir\u65b9\u6cd5function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false),\u5b83\u5b9a\u4e49\u4e865\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e00\u822c\u662f\u4e2a\u6587\u4ef6\u540d,\u5b83\u662f\u7528\u6765\u5224\u65ad\u540e\u4e24\u4e2a\u53c2\u6570\u7ec4\u6210\u7684\u76ee\u5f55\u4e2d\u6709\u6ca1\u6709\u5339\u914d$template_code\u7684\u8fd9\u4e2a\u6587\u4ef6,\u8be5\u7c7b\u590d\u5199\u4e86\u9ed8\u8ba4\u7684\u7cfb\u7edf\u51fd\u6570file_exists\u6240\u4ee5\u5f88\u591a\u521d\u5b66\u8005\u53ef\u80fd\u4f1a\u6bd4\u8f83\u8ff7\u60d1function get_template_dir($template_code, $current_template, $current_page, $template_dir, $debug=false) {&nbsp; &nbsp; if ($this-&gt;file_exists($current_template . $current_page, $template_code)) {&nbsp; &nbsp; &nbsp; return $current_template . $current_page . &#8216;\/&#8217;;&nbsp; &nbsp; } elseif ($this-&gt;file_exists(DIR_WS_TEMPLATES . &#8216;template_default\/&#8217; . $current_page, ereg_replace(&#8216;\/&#8217;, &#8221;, $template_code), $debug)) {&nbsp; &nbsp; &nbsp; return [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-60967","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60967","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=60967"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60967\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60967"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60967"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60967"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}