{"id":199529,"date":"2025-05-03T09:07:02","date_gmt":"2025-05-03T01:07:02","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199529\/"},"modified":"2025-05-03T09:07:02","modified_gmt":"2025-05-03T01:07:02","slug":"%e5%ae%9e%e7%8e%b0ecshop%e5%86%85%e9%a1%b5%e8%b0%83%e7%94%a8%e6%96%b0%e9%97%bb%e5%88%97%e8%a1%a8%e6%9c%80%e6%96%b0%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199529\/","title":{"rendered":"\u5b9e\u73b0ecshop\u5185\u9875\u8c03\u7528\u65b0\u95fb\u5217\u8868\u6700\u65b0\u6587\u7ae0"},"content":{"rendered":"<p>Ecshop\u7684\u65b0\u95fb\u7cfb\u7edf\u4e4b\u7c7b\u7684\u662f\u65e0\u6cd5\u8ddfDedecms\u8fdb\u884c\u6bd4\u8f83\u7684\uff0cEcshop\u4e0d\u80fd\u968f\u610f\u7684\u5728\u81ea\u5df1\u60f3\u8981\u7684\u9875\u9762\u8c03\u7528\u672c\u8eab\u6a21\u677f\u6ca1\u6709\u7684\u9879\u76ee\uff0c\u5982\u679c\u786c\u8981\u7684\u8bdd\uff0c\u53ea\u80fd\u901a\u8fc7\u4fee\u6539\u4e00\u4e9b\u6587\u4ef6\u8fbe\u5230\u6548\u679c<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> \u9996\u5148ecshop\u6253\u5f00article.php \u53ca article_cat.php\u6587\u4ef6\uff0c\u5728\u6587\u4ef6\u4e2d\u52a0\u4e0a\u4e0b\u9762\u4ee3\u7801\uff1a<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> \/**<br \/>\n<br \/> &nbsp;* \u83b7\u5f97\u6700\u65b0\u7684\u6587\u7ae0\u5217\u8868\u3002<br \/>\n<br \/> &nbsp;*<br \/>\n<br \/> &nbsp;* @access&nbsp; private<br \/>\n<br \/> &nbsp;* @return&nbsp; array<br \/>\n<br \/> &nbsp;*\/<br \/>\n<br \/> function index_get_new_articles()<br \/>\n<br \/> {<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; $sql = &#8216;SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name &#8216; .<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; FROM &#8216; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;article&#8217;) . &#8216; AS a, &#8216; .<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;article_cat&#8217;) . &#8216; AS ac&#8217; .<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1&#8217; .<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8216; ORDER BY a.article_type DESC, a.add_time DESC LIMIT &#8216; . $GLOBALS[&#8216;_CFG&#8217;][&#8216;article_number&#8217;];<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; $res = $GLOBALS[&#8216;db&#8217;]-&gt;getAll($sql);<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; $arr = array();<br \/>\n<br \/> &nbsp; &nbsp;&nbsp;foreach ($res AS $idx =&gt; $row)<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; {<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;id&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;article_id&#8217;];<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;titles&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;title&#8217;];<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;short_titles&#8217;] = $GLOBALS[&#8216;_CFG&#8217;][&#8216;article_title_length&#8217;] &gt; 0 ?<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sub_str($row[&#8216;title&#8217;], $GLOBALS[&#8216;_CFG&#8217;][&#8216;article_title_length&#8217;]) : $row[&#8216;title&#8217;];<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;cat_name&#8217;]&nbsp;&nbsp;&nbsp; = $row[&#8216;cat_name&#8217;];<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;add_time&#8217;]&nbsp;&nbsp;&nbsp; = local_date($GLOBALS[&#8216;_CFG&#8217;][&#8216;date_format&#8217;], $row[&#8216;add_time&#8217;]);<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;$arr[$idx][&#8216;urls&#8217;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $row[&#8216;open_type&#8217;] != 1 ?<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; build_uri(&#8216;article&#8217;, array(&#8216;aid&#8217; =&gt; $row[&#8216;article_id&#8217;]), $row[&#8216;title&#8217;]) : trim($row[&#8216;file_url&#8217;]);<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $arr[$idx][&#8216;cat_url&#8217;]&nbsp;&nbsp;&nbsp;&nbsp; = build_uri(&#8216;article_cat&#8217;, array(&#8216;acid&#8217; =&gt; $row[&#8216;cat_id&#8217;]), $row[&#8216;cat_name&#8217;]);<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; }<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp; return $arr;<br \/>\n<br \/> }<br \/>\n<br \/> \u8fd8\u9700\u8981\u52a0\u4e0a\u8fd9\u53e5smarty\u8bed\u53e5\uff1a<br \/>\n<br \/> $smarty-&gt;assign(&#8216;new_articles&#8217;,&nbsp;&nbsp;&nbsp; index_get_new_articles());&nbsp;&nbsp; \/\/ \u6700\u65b0\u6587\u7ae0<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> \u56e0\u4e3a\u7528\u9996\u9875\u7684new_articles.lbi\u4f1a\u66f4\u5185\u9875\u65b0\u95fb\u7684\u6807\u9898\u5185\u5bb9\u4ea7\u751f\u51b2\u7a81\uff0c\u6240\u4ee5\u9700\u8981\u81ea\u5df1\u5efa\u7acb\u4e00\u4e2a\u6587\u4ef6\uff0c\u8fd9\u91cc\u547d\u540d\u4e3aone_article.lbi\u5427\uff0c\u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=utf-8&#8243;&gt;<br \/>\n<br \/> &lt;div class=&#8221;tle-5&#8243;&gt;&lt;a href=&#8221;article_cat.php?id=12&#8243;&gt;NEWS&lt;\/a&gt;&lt;\/div&gt;<br \/>\n<br \/> &lt;div class=&#8221;box-2 pb5&#8243;&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&#8221;list-1 pb10 link1&#8243;&gt;<br \/>\n<br \/> &lt;ul&gt;<br \/>\n<br \/> &lt;!&#8211;{foreach from=$new_articles item=article}&#8211;&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;li&gt;&lt;a href=&#8221;{$article.urls}&#8221; title=&#8221;{$article.titles|escape:html}&#8221;&gt;{$article.short_titles|truncate:20:&#8221;&#8230;&#8221;:true}&lt;\/a&gt;&lt;\/li&gt;<br \/>\n<br \/> &lt;!&#8211;{\/foreach}&#8211;&gt;<br \/>\n<br \/> &lt;\/ul&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/div&gt;<br \/>\n<br \/> &lt;\/div&gt;<br \/>\n<br \/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&#8221;cl&#8221;&gt;&lt;\/div&gt;<br \/>\n<br \/> &nbsp;<br \/>\n<br \/> \u6700\u540e\u5728article.dwt \u3001article_cat.dwt \u3001article_pro.dwt\u6587\u4ef6\u4e2d\u9700\u8981\u663e\u793a\u7684\u4f4d\u7f6e\u8c03\u7528one_article.lbi\u6587\u4ef6\u5373\u53ef\u3002<br \/>\n<br \/> &lt;!&#8211; #BeginLibraryItem &#8220;\/library\/one_article.lbi&#8221; &#8211;&gt;&lt;!&#8211; #EndLibraryItem &#8211;&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ecshop\u7684\u65b0\u95fb\u7cfb\u7edf\u4e4b\u7c7b\u7684\u662f\u65e0&#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-199529","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199529","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=199529"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199529\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}