{"id":199578,"date":"2025-05-03T11:04:22","date_gmt":"2025-05-03T03:04:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199578\/"},"modified":"2025-05-03T11:04:22","modified_gmt":"2025-05-03T03:04:22","slug":"%e4%b8%a4%e7%a7%8d%e5%bd%bb%e5%ba%95%e8%a7%a3%e5%86%b3ecshop%e6%a0%87%e9%a2%98%e5%90%8e%e9%9d%a2%e7%9a%84%ef%bc%82-%ef%bc%82%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199578\/","title":{"rendered":"\u4e24\u79cd\u5f7b\u5e95\u89e3\u51b3ecshop\u6807\u9898\u540e\u9762\u7684\uff02 &#8230;\uff02\u7684\u65b9\u6cd5"},"content":{"rendered":"<p>\u7ecf\u5e38\u770b\u5230ecshop\u8bba\u575b\u6709\u4eba\u5728\u53cd\u5e94 \u6a21\u677f\u4e2d \u8bbe\u7f6e\u4e86{$goods.goods_name|truncate:10:&#8221;}   &nbsp;   \u6807\u9898\u540e\u9762\u8fd8\u662f\u4e00\u6837\u4f1a\u8ddf\u7740 &#8230; \u8fd9\u91cc\u5148\u7ed9\u5927\u5bb6\u8bb2\u8bb2\u539f\u7406   &nbsp;   \u6700\u8fd1\u53d1\u73b0 ec\u7684\u6a21\u677f\u5f15\u64ce\u4e0d\u5b8c\u5168\u662fsmarty \u6240\u4ee5\u5728truncate\u51fd\u6570\u4e0a\u662f\u6709\u533a\u522b\u7684   &nbsp;   \u627e\u5230 cls_template.php \u641c\u7d22truncate \u4f60\u4f1a\u53d1\u73b0\u4ee5\u4e0b\u4ee3\u7801   &nbsp;   case &#8216;truncate&#8217;:   $p = &#8216;sub_str(&#8216; . $p . &#8220;,$s[1])&#8221;;   break;   &nbsp;   &nbsp;   \u8fd9\u91cc\u7684 sub_str\u662fec\u7684\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u5728 lib_base.php\u6587\u4ef6\u4e2d\u7684   \u4ee3\u7801\u5982\u4e0b\uff1a   &nbsp;   function sub_str($str, $length = 0, $append = true)   {   &nbsp; &nbsp; $str = trim($str);   &nbsp; &nbsp; $strlength = strlen($str);   &nbsp; &nbsp; if ($length == 0 || $length &gt;= $strlength)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; return $str;   &nbsp; &nbsp; }   &nbsp; &nbsp; elseif ($length &lt; 0)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $length = $strlength + $length;   &nbsp; &nbsp; &nbsp; &nbsp; if ($length &lt; 0)   &nbsp; &nbsp; &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $length = $strlength;   &nbsp; &nbsp; &nbsp; &nbsp; }   &nbsp; &nbsp; }   &nbsp; &nbsp; if (function_exists(&#8216;mb_substr&#8217;))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $newstr = mb_substr($str, 0, $length, EC_CHARSET);   &nbsp; &nbsp; }   &nbsp; &nbsp; elseif (function_exists(&#8216;iconv_substr&#8217;))   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $newstr = iconv_substr($str, 0, $length, EC_CHARSET);   &nbsp; &nbsp; }   &nbsp; &nbsp; else   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; \/\/$newstr = trim_right(substr($str, 0, $length));   &nbsp; &nbsp; &nbsp; &nbsp; $newstr = substr($str, 0, $length);   &nbsp; &nbsp; }   &nbsp; &nbsp; if ($append &amp;&amp; $str != $newstr)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $newstr .= &#8216;&#8230;&#8217;;   &nbsp; &nbsp; }   &nbsp; &nbsp; return $newstr;   }   &nbsp;   \u5176\u4e2d \u4ed4\u7ec6\u770b   \u8fd9\u4e2a\u51fd\u6570\u67093\u4e2a\u53c2\u6570 \u4f46\u662f\u5728\u6a21\u677f\u5f15\u64ce\u6587\u4ef6\u4e2d\u53ea\u4ee3\u4e862\u4e2a\u53c2\u6570   &nbsp;   \u65b9\u6cd5\u4e00   \u627e\u5230 cls_template.php \u641c\u7d22truncate   &nbsp;   case &#8216;truncate&#8217;:   $p = &#8216;sub_str(&#8216; . $p . &#8220;,$s[1],$s[2])&#8221;;   break;   \u7136\u540e\u5728\u4f60\u7684\u540e\u53f0\u6e05\u9664\u4e00\u4e0b\u7f13\u5b58   1   {$goods.goods_name|truncate:10:false}   &nbsp;   \u5c31\u53ea\u663e\u793a5\u4e2a\u5b57 \u4e5f\u4e0d\u4f1a\u51fa\u73b0&#8230;   &nbsp;   &nbsp;   &nbsp;   \u65b9\u6cd5\u4e8c   \u76f4\u63a5\u5e72\u6389lib_base.php\u4e2d   &nbsp; &nbsp;   &nbsp;   if ($append &amp;&amp; $str != $newstr)   &nbsp; &nbsp; {   &nbsp; &nbsp; &nbsp; &nbsp; $newstr .= &#8216;&#8230;&#8217;;   &nbsp; &nbsp; }   &nbsp;   \u8fd9\u6837{$goods.goods_style_name}\u4e5f\u4e0d\u4f1a\u663e\u793a &#8230;  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ecf\u5e38\u770b\u5230ecshop\u8bba\u575b\u6709\u4eba\u5728\u53cd&#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-199578","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199578","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=199578"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199578\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}