{"id":199513,"date":"2025-05-03T12:41:57","date_gmt":"2025-05-03T04:41:57","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199513\/"},"modified":"2025-05-03T12:41:57","modified_gmt":"2025-05-03T04:41:57","slug":"ecshop%e6%a8%a1%e7%89%88%e7%b3%bb%e7%bb%9fassign%e5%92%8cinclude%e6%a8%a1%e7%89%88%e6%a0%87%e7%ad%be%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199513\/","title":{"rendered":"ECSHOP\u6a21\u7248\u7cfb\u7edfAssign\u548cInclude\u6a21\u7248\u6807\u7b7e\u4ecb\u7ecd"},"content":{"rendered":"<p> CSHOP\u6a21\u7248\u7cfb\u7edfAssign\u548cInclude\u6a21\u7248\u6807\u7b7e\u4ecb\u7ecd\uff0cassign \u7528\u4e8e\u5728\u6a21\u677f\u88ab\u6267\u884c\u65f6\u4e3a\u6a21\u677f\u53d8\u91cf\u8d4b\u503c\uff0cInclude \u6807\u7b7e\u7528\u4e8e\u5728\u5f53\u524d\u6a21\u677f\u4e2d\u5305\u542b\u5176\u5b83\u6a21\u677f. \u5f53\u524d\u6a21\u677f\u4e2d\u7684\u53d8\u91cf\u5728\u88ab\u5305\u542b\u7684\u6a21\u677f\u4e2d\u53ef\u7528\u3002 \u5fc5\u987b\u6307\u5b9a file \u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u6307\u660e\u6a21\u677f\u8d44\u6e90\u7684\u4f4d\u7f6e\u3002\u5982\u679c\u8bbe\u7f6e\u4e86 assign \u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u5bf9\u5e94\u7684\u53d8\u91cf\u540d\u7528\u4e8e\u4fdd\u5b58\u5f85\u5305\u542b\u6a21\u677f\u7684\u8f93\u51fa\uff0c\u8fd9\u6837\u5f85\u5305\u542b\u6a21\u677f\u7684\u8f93\u51fa\u5c31\u4e0d\u4f1a\u76f4\u63a5\u663e\u793a\u4e86\u3002<\/p>\n<h2> Assign<\/h2>\n<table border=\"0\">\n<tbody>\n<tr>\n<td> \u5c5e\u6027<\/td>\n<td> \u7c7b\u578b<\/td>\n<td> \u662f\u5426\u5fc5\u987b<\/td>\n<td> \u7f3a\u7701\u503c<\/td>\n<td> \u63cf\u8ff0<\/td>\n<\/tr>\n<tr>\n<td> var<\/td>\n<td> string<\/td>\n<td> Yes<\/td>\n<td> N\/A<\/td>\n<td> \u88ab\u8d4b\u503c\u7684\u53d8\u91cf\u540d<\/td>\n<\/tr>\n<tr>\n<td> value<\/td>\n<td> string<\/td>\n<td> Yes<\/td>\n<td> N\/A<\/td>\n<td> \u8d4b\u7ed9\u53d8\u91cf\u7684\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> \u63cf\u8ff0\uff1a<\/p>\n<p> assign \u7528\u4e8e\u5728\u6a21\u677f\u88ab\u6267\u884c\u65f6\u4e3a\u6a21\u677f\u53d8\u91cf\u8d4b\u503c.<\/p>\n<p> \u4f8b\u5b50\uff1a<\/p>\n<pre>\r\n{assign var=\"name\" value=\"Bob\"}<\/pre>\n<p> \u8f93\u51fa\uff1a<\/p>\n<pre>\r\nThe value of $name is Bob.<\/pre>\n<h2> Include<\/h2>\n<table border=\"0\">\n<tbody>\n<tr>\n<td> \u5c5e\u6027<\/td>\n<td> \u7c7b\u578b<\/td>\n<td> \u662f\u5426\u5fc5\u987b<\/td>\n<td> \u7f3a\u7701\u503c<\/td>\n<td> \u63cf\u8ff0<\/td>\n<\/tr>\n<tr>\n<td> file<\/td>\n<td> string<\/td>\n<td> Yes<\/td>\n<td> N\/A<\/td>\n<td> \u5f85\u5305\u542b\u7684\u6a21\u677f\u6587\u4ef6\u540d<\/td>\n<\/tr>\n<tr>\n<td> assign<\/td>\n<td> string<\/td>\n<td> Yes<\/td>\n<td> N\/A<\/td>\n<td> \u8be5\u5c5e\u6027\u6307\u5b9a\u4e00\u4e2a\u53d8\u91cf\u4fdd\u5b58\u5f85\u5305\u542b\u6a21\u677f\u7684\u8f93\u51fa<\/td>\n<\/tr>\n<tr>\n<td> [var \u2026]<\/td>\n<td> [var type]<\/td>\n<td> Yes<\/td>\n<td> N\/A<\/td>\n<td> \u4f20\u9012\u7ed9\u5f85\u5305\u542b\u6a21\u677f\u7684\u672c\u5730\u53c2\u6570\uff0c\u53ea\u5728\u5f85\u5305\u542b\u6a21\u677f\u4e2d\u6709\u6548<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p> \u63cf\u8ff0\uff1a<\/p>\n<p> Include \u6807\u7b7e\u7528\u4e8e\u5728\u5f53\u524d\u6a21\u677f\u4e2d\u5305\u542b\u5176\u5b83\u6a21\u677f. \u5f53\u524d\u6a21\u677f\u4e2d\u7684\u53d8\u91cf\u5728\u88ab\u5305\u542b\u7684\u6a21\u677f\u4e2d\u53ef\u7528\u3002\u5fc5\u987b\u6307\u5b9a file \u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u6307\u660e\u6a21\u677f\u8d44\u6e90\u7684\u4f4d\u7f6e\u3002<\/p>\n<p> \u5982\u679c\u8bbe\u7f6e\u4e86 assign \u5c5e\u6027\uff0c\u8be5\u5c5e\u6027\u5bf9\u5e94\u7684\u53d8\u91cf\u540d\u7528\u4e8e\u4fdd\u5b58\u5f85\u5305\u542b\u6a21\u677f\u7684\u8f93\u51fa\uff0c\u8fd9\u6837\u5f85\u5305\u542b\u6a21\u677f\u7684\u8f93\u51fa\u5c31\u4e0d\u4f1a\u76f4\u63a5\u663e\u793a\u4e86\u3002<\/p>\n<p> \u4f8b\u5b501\uff1a<\/p>\n<pre>\r\n{include file=\"header.tpl\"}\r\n{* body of template goes here *}\r\n{include file=\"footer.tpl\"}<\/pre>\n<p> \u53ef\u4ee5\u5728\u5c5e\u6027\u4e2d\u4f20\u9012\u53c2\u6570\u7ed9\u5f85\u5305\u542b\u6a21\u677f. \u4f20\u9012\u7ed9\u5f85\u5305\u542b\u6a21\u677f\u7684\u53c2\u6570\u53ea\u5728\u5f85\u5305\u542b\u6a21\u677f\u4e2d\u53ef\u89c1. \u5982\u679c\u4f20\u9012\u7684\u53c2\u6570\u5728\u5f85\u5305\u542b\u6a21\u677f\u4e2d\u6709\u540c\u540d\u53d8\u91cf\uff0c\u90a3\u4e48\u8be5\u53d8\u91cf\u88ab\u4f20\u9012\u7684\u53c2\u6570\u66ff\u4ee3\u3002<\/p>\n<p> \u4f8b\u5b502\uff1a<\/p>\n<pre>\r\n{include file=\"header.tpl\" title=\"Main Menu\" table_bgcolor=\"#c0c0c0\"}\r\n{* body of template goes here *}\r\n{include file=\"footer.tpl\" logo=\"http:\/\/my.domain.com\/logo.gif\"}<\/pre>\n<p> \u5305\u542b $template_dir \u6587\u4ef6\u5939\u4e4b\u5916\u7684\u6a21\u677f\u8bf7\u4f7f\u7528 \u6a21\u677f\u8d44\u6e90 \u8bf4\u660e\u7684\u683c\u5f0f.<\/p>\n<p> \u4f8b\u5b503\uff1a<\/p>\n<pre>\r\n{* absolute filepath *}\r\n{include file=\"\/usr\/local\/include\/templates\/header.tpl\"}\r\n{* absolute filepath (same thing) *}\r\n{include file=\"file:\/usr\/local\/include\/templates\/header.tpl\"}\r\n{* windows absolute filepath (MUST use \"file:\" prefix) *}\r\n{include file=\"file:C:\/www\/pub\/templates\/header.tpl\"}\r\n{* include from template resource named \"db\" *}\r\n{include file=\"db:header.tpl\"}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CSHOP\u6a21\u7248\u7cfb\u7edfAssign\u548c&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199513","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199513"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199513\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}