{"id":199292,"date":"2025-05-03T08:38:59","date_gmt":"2025-05-03T00:38:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199292\/"},"modified":"2025-05-03T08:38:59","modified_gmt":"2025-05-03T00:38:59","slug":"ecshop%e5%b1%9e%e6%80%a7-goods-goods_attrnl2br-%e6%a0%87%e7%ad%be%e7%9a%84%e8%b5%8b%e5%80%bc%e7%9b%b8%e5%85%b3","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199292\/","title":{"rendered":"ecshop\u5c5e\u6027 {$goods.goods_attr|nl2br} \u6807\u7b7e\u7684\u8d4b\u503c\u76f8\u5173"},"content":{"rendered":"<p>&nbsp;<span style=\"font-size: 13px;line-height: 19px;text-align: left\">1\u3001nl2br() \u51fd\u6570\u5728\u5b57\u7b26\u4e32\u4e2d\u7684\u6bcf\u4e2a\u65b0\u884c (\\n) \u4e4b\u524d\u63d2\u5165 HTML \u6362\u884c\u7b26 (&lt;br \/&gt;)\u3002<\/span><\/p>\n<pre>\r\n2\u3001 \u5982\u679c\u8981\u5411{$goods.goods_attr|nl2br}\u8d4b\u65b0\u503c\uff0c\u8fd9\u4e2a\u503c\u662f\u4fdd\u5b58\u5728\u6570\u636e\u5e93\u4e2d\u7684\uff0c\u7528\u6237\u5728\u5546\u54c1\u9875(goods.php)\u9009\u62e9\u4e86\u5546\u54c1\u5c5e\u6027(goods.attr)\u4e4b\u540e\uff0c\u70b9\u51fb\"\u8d2d\u4e70\"\u5c31\u4f1a\u8fdb\u5165\u8d2d\u7269\u8f66\u9875\u9762(flow.php)\uff0c\u540c\u65f6\uff0c\u5c06\u7528\u6237\u9009\u62e9\u7684\u5546\u54c1\u5c5e\u6027(goods.attr)\u4fdd\u5b58\u8fdb\u4e86\u6570\u636e\u5e93\uff0c\u5f53\u8fdb\u5165\u8d2d\u7269\u8f66\u9875\u9762\u7684\u65f6\u5019\uff0c\u697c\u4e3b\u53ef\u4ee5\u770bflow.dwt\u7684\u4ee3\u7801\uff08&lt;!-- {foreach from=$goods_list item=goods} --&gt;\uff09\uff0c\u90a3\u4e48{$goods.goods_attr}\u8fd9\u4e2a\u4e1c\u897f\u7684\u503c\u6765\u81ea\u4e8eflow.php\u4e2d\u7684$goods_list\uff0c\u67e5\u770bflow.php\uff0c\u4f1a\u53d1\u73b0\uff0c$goods_list\u7684\u503c\u6765\u81eacart_goods()\u8fd9\u4e2a\u65b9\u6cd5\uff0ccart_goods()\u8fd9\u4e2a\u65b9\u6cd5\u5728includes\/lib_order.php\u5185\uff0c\u90a3\u91cc\u9762\u6709\u4e00\u6bb5sql\r\n\uff08$sql = \"SELECT \u3002\u3002\u3002, \" .\r\n            \"\u3002\u3002\u3002, goods_attr\uff08\u91cd\u70b9\uff09,\u3002\u3002\u3002, \" .\r\n            \"\u3002\u3002\u3002 \" .\r\n            \"FROM \" . $GLOBALS['ecs']-&gt;table('cart') .\r\n            \" WHERE session_id = '\" . SESS_ID . \"' \" .\r\n            \"AND rec_type = '$type'\";\uff09\r\n\uff0c\u8fd9\u4e2asql\u91cc\u9762\u7684goods_attr\u5c31\u662f\u697c\u4e3b\u4f60\u60f3\u8981\u7684\u503c\uff0c\u5b83\u6765\u81ea\u6570\u636e\u8868cart\uff0c\u800c\u7528\u6237\u5bf9\u4e8e\u5546\u54c1\u5c5e\u6027\u7684\u9009\u62e9\u51b3\u5b9a\u4e86cart\u8fd9\u4e2a\u8868\u7684goods_attr\u4fdd\u5b58\u4ec0\u4e48\u6837\u7684\u503c\u3002\r\n\u53e6\u5916\u4e00\u4e2a\u5f71\u54cd{$goods.goods_attr}\u503c\u7684\u65b9\u6cd5\u662fincludes\/lib_order.php\u5185\u7684get_goods_attr_info(),\u4e0d\u8fc7\u8fd9\u4e2a\u65b9\u6cd5\u4e0d\u80fd\u51b3\u5b9a\u5546\u54c1\u7684\u5c5e\u6027\uff0c\u800c\u662f\u51b3\u5b9a\u5546\u54c1\u5c5e\u6027\u7684\u663e\u793a\u65b9\u5f0f\uff0c\u5b83\u91cc\u9762\u6709\u4e00\u6bb5\u4ee3\u7801\uff1a$fmt = \"%s:%s[%s] \\n\";\uff0c\u8fd9\u4e2a\u5728\u8d2d\u7269\u8f66\u663e\u793a\u51fa\u6765\u7684\u6837\u5b50\u5c31\u662f\uff08\u4f8b\u5982\uff09\uff1a\u989c\u8272:#ff0\uff0c\u6211\u628a\u5b83\u6539\u4e86\uff1a$fmt = \"&lt;td&gt;%s:&lt;\/td&gt;&lt;td&gt;%s&lt;\/td&gt;&lt;td&gt;[%s]&lt;\/td&gt; \\n\";\uff0c \u4e5f\u53ef\u4ee5\u6309\u81ea\u5df1\u7684\u559c\u597d\u6765\u6539\u3002<br><br><br><\/pre>\n<pre>\r\n   $fmt = <span style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;line-height: 1.5\">\"<\/span><span style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;line-height: 1.5\"> &lt;label class=xxlblName&gt;%s&lt;\/label&gt;:%s[%s] <\/span><span style=\"margin-top: 0px;margin-right: 0px;margin-bottom: 0px;margin-left: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;line-height: 1.5\">\"<\/span>;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;1\u3001nl2br() &#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-199292","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199292","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=199292"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199292\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}