{"id":199424,"date":"2025-05-03T08:08:26","date_gmt":"2025-05-03T00:08:26","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199424\/"},"modified":"2025-05-03T08:08:26","modified_gmt":"2025-05-03T00:08:26","slug":"%e4%bc%98%e5%8c%96%e4%b8%baecshop%e6%96%87%e7%ab%a0%e6%b7%bb%e5%8a%a0%e7%9b%b8%e4%bc%bc%e5%85%b3%e8%81%94%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199424\/","title":{"rendered":"\u4f18\u5316\u4e3aecshop\u6587\u7ae0\u6dfb\u52a0\u76f8\u4f3c\u5173\u8054\u6587\u7ae0"},"content":{"rendered":"<p>\u4e3a ecshop \u6587\u7ae0\u589e\u52a0\u6709\u5173\u6587\u7ae0\uff0c\u8fd9\u513f\u7684\u6709\u5173\u5176\u5b9e\u5373\u662f\u7c7b\u4f3c\u6587\u7ae0\u4e86\u5427\uff0c\u5047\u5982\u7ecf\u5e38\u770b\u65b0\u95fb\u7f51\u7ad9\u7684\u8bdd\uff0c\u4f1a\u5bf9\u8fd9\u4e2a\u6709\u5173\u5f88\u4e86\u89e3\u4e86\uff0c\u6bd4\u5982\u54b1\u4eec\u770b\u5a31\u4e50\u7248\u5757\u7684\u65b0\u95fb\uff0c\u67d0\u7bc7\u5a31\u4e50\u65b0\u95fb\u4e0b\u9762\u4e00\u5b9a\u6709\u5176\u76f8\u6709\u5173\u7684\u6587\u7ae0\uff0c\u8fd9\u4e48\u5c31\u589e\u52a0\u4e86\u5176\u6587\u7ae0\u7684\u7c98\u6027\uff0c\u5728\u6bcf\u4e00\u7bc7\u6587\u7ae0\u4e0b\u9762\u4e5f\u6709\u5176\u6709\u5173\u6587\u7ae0\uff0c\u8bf4\u767d\u4e86\u5373\u662f\u7c7b\u4f3c\u5ea6\u8f83\u9ad8\u7684\u6587\u7ae0\u4e86\uff0c\u597d\u4e86\u8bf4\u4e86\u600e\u6837\u591a\uff0c\u4e0b\u9762\u54b1\u4eec\u6765\u770b\u4e00\u4e0b\u8be6\u7ec6\u5b8c\u6210\u7684\u529e\u6cd5\u5427\u3002<br \/>\n<br \/>  \u4e00\uff0c\u9996\u5148\u9700\u8981\u5728 mysql \u4e2d\u8fd0\u884c\u4e00\u4e0b sql \u8bed\u53e5:   &nbsp;   INSERT INTO &nbsp;`ecs_shop_config` (`id` , `parent_id` , `code` , `type` , `store_range` , `store_dir` , `value` , `sort_order`)   VALUES ( &#8216;399&#8217;, &nbsp;&#8216;3&#8217;, &nbsp;&#8216;article_related&#8217;, &nbsp;&#8216;select&#8217;, &nbsp;&#8216;0,1&#8217;, &nbsp;&#8221;, &nbsp;&#8216;1&#8217;, &nbsp;&#8216;1&#8217;);   ALTER TABLE &nbsp;`ecs_article` ADD INDEX ( &nbsp;`keywords` );   \u4e8c\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6 article_related.lbi\uff0c\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u8fdb\u53bb\uff0c\u7136\u540e\u4e0a\u4f20\u5230 \/themes\/default\/library\/ \u76ee\u5f55\u4e0b.   &nbsp;   &lt;?php   $sql_where = &#8221; where is_open=1 and article_id != &#8216;&#8221; .$GLOBALS[&#8216;article&#8217;][&#8216;article_id&#8217;] . &#8220;&#8216; &#8220;;   if ( $GLOBALS[&#8216;_CFG&#8217;][&#8216;article_related&#8217;] == &#8216;1&#8217; )   {   $sql_where .= &#8221; and cat_id = &#8216;&#8221; . $GLOBALS[&#8216;article&#8217;][&#8216;cat_id&#8217;] . &#8220;&#8216; &#8220;;   }   elseif ( $GLOBALS[&#8216;_CFG&#8217;][&#8216;article_related&#8217;] == &#8216;0&#8217; )   {   \/\/\u901a\u8fc7\u5173\u952e\u5b57\u5173\u8054   if ($GLOBALS[&#8216;article&#8217;][&#8216;keywords&#8217;])   {   &nbsp; $GLOBALS[&#8216;article&#8217;][&#8216;keywords&#8217;] = str_replace(&#8220;\uff0c&#8221;, &nbsp;&#8220;,&#8221; , $GLOBALS[&#8216;article&#8217;][&#8216;keywords&#8217;]);   &nbsp; $key_list=explode(&#8220;,&#8221;, $GLOBALS[&#8216;article&#8217;][&#8216;keywords&#8217;]);   &nbsp; $key_id=0;   &nbsp; $sql_or=&#8221;&#8221;;   &nbsp; foreach ($key_list as $keyword)   &nbsp; { &nbsp;&nbsp;   &nbsp; &nbsp;$sql_or .= $key_id ? &#8221; or &#8221; : &#8220;&#8221;;   &nbsp; &nbsp;$sql_or .= &#8221; keywords like &#8216;%&#8221; . trim($keyword) . &#8220;%&#8217; &#8220;;   &nbsp; &nbsp;$key_id++;   &nbsp; }   &nbsp; $sql_or = &#8221; ( &#8220;. $sql_or .&#8221; ) &#8220;;   &nbsp; $sql_where .= &#8221; and &#8221; . $sql_or ;   }   }   $sql=&#8221;select article_id, cat_id, title, open_type, file_url from &#8221; . $GLOBALS[&#8216;ecs&#8217;]-&gt;table(&#8216;article&#8217;) . &#8221; $sql_where limit 0,10 &#8220;;   \/\/echo $sql;   $res_art_rel=$GLOBALS[&#8216;db&#8217;]-&gt;query($sql);   while ( $row_art_rel = $GLOBALS[&#8216;db&#8217;]-&gt;fetchRow($res_art_rel) )   {   $row_art_rel[&#8216;url&#8217;]=$row_art_rel[&#8216;open_type&#8217;] != 1 ? build_uri(&#8216;article&#8217;, array(&#8216;aid&#8217;=&gt;$row_art_rel[&#8216;article_id&#8217;]), $row_art_rel[&#8216;title&#8217;]) : trim($row_art_rel[&#8216;file_url&#8217;]);   $art_rel_list[]=$row_art_rel;   }   $GLOBALS[&#8216;smarty&#8217;]-&gt;assign(&#8216;art_rel_list&#8217;, $art_rel_list);   ?&gt;   &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=gbk&#8221;&gt;   &lt;style&gt;   .art_rel_tit{clear:both;width:98%;font-size:17px;font-weight:bold;padding:8px 0; margin-top:15px; text-align:left; border-bottom:1px solid #ccc;}   .art_rel_box{width:98%;padding:8px 0;}   .art_rel_box ul{width:100%;}   .art_rel_box ul li{float:left;width:300px;height:25px;}   .art_rel_box ul li a{text-decoration:none;color:#000;}   .art_rel_box ul li a:hover{text-decoration:underline;color:#ff3300;}   &lt;\/style&gt;   &lt;div class=&#8221;art_rel_tit&#8221;&gt;\u76f8\u5173\u6587\u7ae0&lt;\/div&gt;   &lt;div class=&#8221;art_rel_box&#8221;&gt;   &lt;ul&gt;   {foreach from=$art_rel_list item=art_rel}   &lt;li&gt;? &lt;a href=&#8221;{$art_rel.url}&#8221; target=&#8221;_blank&#8221;&gt;{$art_rel.title}&lt;\/a&gt;&lt;\/li&gt;   {\/foreach}   &lt;\/ul&gt;   &lt;\/div&gt;   &lt;div style=&#8221;clear:both;&#8221;&gt;&lt;br&gt;&lt;\/div&gt;   \u6ce8\u610f\u4fdd\u5b58\u7f16\u7801\u7684\u683c\u5f0f\u8981\u4e0e\u6574\u7ad9\u7684\u683c\u5f0f\u4e00\u81f4\uff0c\u5426\u5219\u4f1a\u51fa\u73b0\u4e71\u7801\u7684\u60c5\u51b5\u3002   \u4e09\uff0c\u4fee\u6539\u6a21\u677f\u6587\u4ef6 \/themes\/default\/article.dwt\uff0c\u6253\u5f00\u540e\u641c\u7d22\u5982\u4e0b\u4ee3\u7801:   &nbsp;   \u201c &nbsp;&lt;!&#8211; {if $article.content } &#8211;&gt;{$article.content}&lt;!&#8211; {\/if} &#8211;&gt; \u201d \uff0c   \u5728\u8fd9\u6bb5\u4ee3\u7801\u7684\u540e\u9762\u6dfb\u52a0\u5982\u4e0b\u4e00\u6bb5\u4ee3\u7801\uff0c\u4f4d\u7f6e\u6839\u636e\u81ea\u5df1\u7684\u7ad9\u70b9\u8fdb\u884c\u8c03\u6574.   &nbsp;   &lt;!&#8211; #BeginLibraryItem &#8220;\/library\/article_related.lbi&#8221; &#8211;&gt;&lt;!&#8211; #EndLibraryItem &#8211;&gt;   \u56db\uff0c\u4fee\u6539 \/languages\/zh_cn\/admin\/shop_config.php \u6587\u4ef6\uff0c\u5728\u6587\u4ef6\u7684\u6700\u540e\u6dfb\u52a0\u4e0a\u5982\u4e0b\u4ee3\u7801:   &nbsp;   $_LANG[&#8216;cfg_name&#8217;][&#8216;article_related&#8217;] = &#8216;\u76f8\u5173\u6587\u7ae0\u6765\u6e90&#8217;;   $_LANG[&#8216;cfg_desc&#8217;][&#8216;article_related&#8217;] = &#8216;\u8bbe\u5b9a\u6587\u7ae0\u8be6\u60c5\u9875 \u201c\u76f8\u5173\u6587\u7ae0\u201d \u5982\u4f55\u5173\u8054&#8217;;   $_LANG[&#8216;cfg_range&#8217;][&#8216;article_related&#8217;][0] = &#8216;\u901a\u8fc7\u5173\u952e\u5b57\u5173\u8054&#8217;;   $_LANG[&#8216;cfg_range&#8217;][&#8216;article_related&#8217;][1] = &#8216;\u901a\u8fc7\u6587\u7ae0\u7c7b\u522b\u5173\u8054&#8217;;   OK\uff0c\u6240\u6709\u64cd\u4f5c\u90fd\u5df2\u7ecf\u5b8c\u6210\u4e86\uff0c\u5728\u540e\u53f0\u8fdb\u884c\u6e05\u7406\u4e00\u4e0b\u7f13\u5b58\uff0c\u5728\u524d\u53f0\u9884\u89c8\u4e00\u4e0b\u5427\u3002  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a ecshop \u6587\u7ae0\u589e\u52a0\u6709\u5173\u6587&#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-199424","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199424","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=199424"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199424\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}