{"id":59164,"date":"2025-04-23T08:52:40","date_gmt":"2025-04-23T00:52:40","guid":{"rendered":"https:\/\/fwq.ai\/blog\/59164\/"},"modified":"2025-04-23T08:52:40","modified_gmt":"2025-04-23T00:52:40","slug":"ecshop%e9%a6%96%e9%a1%b5%e8%b0%83%e7%94%a8%e6%9c%80%e6%96%b0%e8%af%84%e8%ae%ba%ef%bc%88%e5%a2%9e%e5%8a%a0%e6%98%be%e7%a4%ba%e8%af%84%e8%ae%ba%e6%97%b6%e9%97%b4%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/59164\/","title":{"rendered":"ECShop\u9996\u9875\u8c03\u7528\u6700\u65b0\u8bc4\u8bba+\uff08\u589e\u52a0\u663e\u793a\u8bc4\u8bba\u65f6\u95f4\uff09"},"content":{"rendered":"<p>\u5728\u5e93<span>\u76ee\u5f55<\/span>\u91cc\u589e\u52a0\u4e00\u4e2a<span>\u6587\u4ef6<\/span>:index_comments.lbi \u91cc\u9762\u6709\u5185\u5bb9\u5982\u4e0b:<\/p>\n<p> &lt;?php<br \/> if(!function_exists(&#8220;get_comments&#8221;)){<br \/> function get_comments($num)<br \/> {<br \/> &nbsp;&nbsp; $sql = &#8216;SELECT * FROM &#8216;. $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;comment&#8217;) .<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; WHERE status = 1 AND parent_id = 0 and comment_type=0 &#8216;.<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; ORDER BY add_time DESC&#8217;;<br \/> &nbsp; if ($num &gt; 0)<br \/> &nbsp; {<br \/> &nbsp;&nbsp; $sql .= &#8216; LIMIT &#8216; . $num;<br \/> &nbsp; }<br \/> &nbsp; \/\/echo $sql;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/> &nbsp; $res = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($sql);<br \/> &nbsp; $comments = array();<br \/> &nbsp; foreach ($res AS $idx =&gt; $row)<br \/> &nbsp; {<br \/> &nbsp;&nbsp; $comments[$idx][&#8216;add_time&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $comments[$idx][&#8216;add_time&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = local_date<br \/> ($GLOBALS[&#8216;_CFG&#8217;][&#8216;time_format&#8217;], $row[&#8216;add_time&#8217;]);<br \/> &nbsp;&nbsp; $comments[$idx][&#8216;user_name&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;user_name&#8217;];<br \/> &nbsp;&nbsp; $comments[$idx][&#8216;content&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;content&#8217;];<br \/> &nbsp;&nbsp; $comments[$idx][&#8216;id_value&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;id_value&#8217;];<br \/> &nbsp; }<br \/> &nbsp; return $comments;<br \/> }<br \/> }<br \/> ?&gt;<br \/> &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=utf-8&#8243;&gt;<br \/> &lt;!&#8211;\u6570\u636e\u8c03\u7528-\u6700\u65b0\u8bc4\u8bba\u5f00\u59cb &#8211;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br \/> &lt;?php<br \/> &nbsp;&nbsp; $this-&gt;assign(&#8216;my_comments&#8217;,get_comments(10)); \/\/ 10\u6761\u6570\u636e<br \/> ?&gt;<br \/> &nbsp; &lt;div class=&#8221;comments&#8221;&gt;<br \/> &lt;!&#8211;{foreach from=$my_comments item=comments}&#8211;&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&#8221;t_l f_l&#8221;&gt;&lt;a href=&#8221;goods.php?id={$comments.id_value}&#8221; target=&#8221;_blank&#8221;&gt;<br \/> {$comments.content|truncate:15:&#8221;&#8221;}&lt;\/a&gt;&lt;\/div&gt;&lt;div class=&#8221;d_r f_r&#8221;&gt;\u65f6\u95f4\uff1a<br \/> {$comments.add_time}&lt;\/div&gt;<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!&#8211;{\/foreach}&#8211;&gt;<br \/> &nbsp; &lt;\/div&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u9996\u9875\u8c03\u7528\u8fd9\u4e2a\u5e93\u6587\u4ef6\u5c31OK\u4e86.<\/p>\n<p>&nbsp;<\/p>\n<p> &lt;!&#8211; #BeginLibraryItem &#8220;\/library\/index_comments.lbi&#8221; &#8211;&gt;&nbsp; &lt;!&#8211; #EndLibraryItem &#8211;&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5e93\u76ee\u5f55\u91cc\u589e\u52a0\u4e00\u4e2a\u6587\u4ef6:index_comments.lbi \u91cc\u9762\u6709\u5185\u5bb9\u5982\u4e0b: &lt;?php if(!function_exists(&#8220;get_comments&#8221;)){ function get_comments($num) { &nbsp;&nbsp; $sql = &#8216;SELECT * FROM &#8216;. $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;comment&#8217;) . &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; WHERE status = 1 AND parent_id = 0 and comment_type=0 &#8216;. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; ORDER BY add_time DESC&#8217;; &nbsp; if ($num &gt; 0) &nbsp; { &nbsp;&nbsp; $sql .= &#8216; LIMIT &#8216; . $num; &nbsp; } &nbsp; \/\/echo $sql; [&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-59164","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59164","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=59164"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/59164\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=59164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=59164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=59164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}