{"id":31464,"date":"2024-11-25T13:05:02","date_gmt":"2024-11-25T05:05:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31464\/"},"modified":"2024-11-25T13:05:02","modified_gmt":"2024-11-25T05:05:02","slug":"phpcms%e5%a6%82%e4%bd%95%e8%b0%83%e5%8f%96%e6%9c%80%e8%bf%91%e6%9b%b4%e6%96%b0%e7%9a%84%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31464\/","title":{"rendered":"phpcms\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5ed22a3db9581327.jpg\" class=\"aligncenter\" title=\"phpcms\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0\u63d2\u56fe\" alt=\"phpcms\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0\u63d2\u56fe\" \/><\/strong><\/p>\n<p>\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>phpcms<\/strong><strong>\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0\uff1f<\/strong><\/p>\n<p><strong>phpcms v9\u8c03\u7528\u5168\u7ad9\u6700\u65b0\u6587\u7ae0\uff08\u6700\u8fd1\u66f4\u65b0\u6240\u6709\u5185\u5bb9\uff09<\/strong><\/p>\n<p>\u7b2c\u4e00\u6b65 \u4fee\u6539 phpcmsmodulescontentclasses&nbsp; content_tag.class.php&nbsp; \u5728\u6700\u540e\u9762\u7684 } \u4e0a\u9762\u6dfb\u52a0<\/p>\n<pre>public&nbsp;function&nbsp;newcontent($data){\n$num&nbsp;=&nbsp;intval($data['limit'])&nbsp;?&nbsp;intval($data['limit'])&nbsp;:&nbsp;'20';\n\/\/&nbsp;\u8bbe\u7f6e\u6392\u5e8f\nswitch($data['order']){\ncase&nbsp;'1':\n$order&nbsp;=&nbsp;'&nbsp;`id`&nbsp;ASC&nbsp;';\nbreak;\ncase&nbsp;'2':\n$order&nbsp;=&nbsp;'&nbsp;`id`&nbsp;DESC&nbsp;';\nbreak;\ncase&nbsp;'3':\n$order&nbsp;=&nbsp;'&nbsp;`inputtime`&nbsp;ASC&nbsp;';\nbreak;\ncase&nbsp;'4':\n$order&nbsp;=&nbsp;'&nbsp;`inputtime`&nbsp;DESC&nbsp;';\nbreak;\ncase&nbsp;'5':\n$order&nbsp;=&nbsp;'&nbsp;`updatetime`&nbsp;ASC&nbsp;';\nbreak;\ncase&nbsp;'6':\n$order&nbsp;=&nbsp;'&nbsp;`updatetime`&nbsp;DESC&nbsp;';\nbreak;\ndefault:\n$order&nbsp;=&nbsp;'&nbsp;`id`&nbsp;DESC&nbsp;';\n}\nif($data['catid']){\n$catids&nbsp;=&nbsp;explode(',',&nbsp;$data['catid']);\nforeach($catids&nbsp;as&nbsp;$catid){\n$catid&nbsp;=&nbsp;intval($catid);\nif(empty($catid))continue;\n$this-&amp;gt;set_modelid($catid);\n$where&nbsp;=&nbsp;$this-&amp;gt;category[$catid]['child']&nbsp;?&nbsp;'&nbsp;`catid`&nbsp;IN&nbsp;('.$this-&amp;gt;category[$catid]['arrchildid'].')'&nbsp;:&nbsp;\"&nbsp;`catid`&nbsp;=&nbsp;$catid\";\n$datas&nbsp;=&nbsp;$this-&amp;gt;db-&amp;gt;select($where,&nbsp;'*',&nbsp;$num,&nbsp;$order);\n$data[$catid]['data']&nbsp;=&nbsp;$datas;\n\/\/&nbsp;\u8bb0\u5f55\u672c\u6b21\u7684\u6587\u7ae0\u6570\n$data['num'][]&nbsp;=&nbsp;count($datas);\n$model_num++;\n}\n}else{\n$models&nbsp;=&nbsp;getcache('model',&nbsp;'commons');\nforeach($models&nbsp;as&nbsp;$model){\n$this-&amp;gt;db-&amp;gt;set_model($model['modelid']);\n$datas&nbsp;=&nbsp;$this-&amp;gt;db-&amp;gt;select('',&nbsp;'*',&nbsp;$num,&nbsp;$order);\n$data[$model['modelid']]['data']&nbsp;=&nbsp;$datas;\n\/\/&nbsp;\u8bb0\u5f55\u672c\u6b21\u7684\u6587\u7ae0\u6570\n$data['num'][]&nbsp;=&nbsp;count($datas);\n$model_num++;\n}\n}\nif($data){\n\/\/&nbsp;\u83b7\u53d6\u6bcf\u4e2a\u6a21\u578b\u5e94\u8be5\u622a\u53d6\u7684\u6761\u6570\n$num&nbsp;=&nbsp;ceil($num\/$model_num);\n\/\/&nbsp;\u5faa\u73af\u6761\u6570\u8bb0\u5f55\u7528\u4e8e\u627e\u51fa\u6761\u6570\u4e0d\u6ee1\u8db3\u7684\u6570\u91cf\u7136\u540e\u8fdb\u884c\u5e73\u5747\n$w_num&nbsp;=&nbsp;$w_num_t&nbsp;=&nbsp;'';\nforeach($data['num']&nbsp;as&nbsp;$num_t){\nif($num_t&nbsp;&lt;p&gt;\u7b2c\u4e8c\u6b65\uff1a\u6a21\u677f\u8c03\u7528&nbsp;&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;&lt;span&gt;\u7acb\u5373\u5b66\u4e60&lt;\/span&gt;\u201c&lt;a href=\"https:\/\/pan.quark.cn\/s\/7fc7563c4182\" style=\"text-decoration: underline !important; color: blue; font-weight: bolder;\" rel=\"nofollow\" target=\"_blank\"&gt;PHP\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09&lt;\/a&gt;\u201d\uff1b&lt;\/p&gt;&lt;p&gt;\u5176\u5b9e\u5c31\u548c\u9ed8\u8ba4\u7684\u6587\u7ae0\u5217\u8868\u8c03\u7528\u5dee\u4e0d\u591a&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;&lt;span&gt;\u7acb\u5373\u5b66\u4e60&lt;\/span&gt;\u201c&lt;a href=\"https:\/\/pan.quark.cn\/s\/7fc7563c4182\" style=\"text-decoration: underline !important; color: blue; font-weight: bolder;\" rel=\"nofollow\" target=\"_blank\"&gt;PHP\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09&lt;\/a&gt;\u201d\uff1b&lt;\/p&gt;&lt;pre class=\"brush:php;toolbar:false\"&gt;{pc:content&nbsp;action=\"newcontent\"&nbsp;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>&nbsp;<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<p>&nbsp;<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>catid: \u53ef\u6709\u53ef\u65e0&nbsp; \u52a0\u4e86\u5c31\u53ea\u8c03\u7528\u6307\u5b9a\u680f\u76ee\u7684\u4fe1\u606f&nbsp; \u591a\u4e2a\u680f\u76ee\u8bf7\u4f7f\u7528\u82f1\u6587\u534a\u89d2\u7684 ,\u95f4\u9694<\/p>\n<p>&nbsp;<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>order:\u6392\u5e8f \u53c2\u6570\u503c\uff1a1-7&nbsp; \u5177\u4f53\u7684\u542b\u4e49\u5728\u4ee3\u7801\u91cc\u9762\u5f88\u5bb9\u6613\u770b\u660e\u767d \u4e0d\u7965\u8ff0<\/p>\n<p>&nbsp;<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>num:\u8c03\u7528\u6570\u91cf&nbsp; \u4e0d\u6307\u5b9a\u9ed8\u8ba4\u8c03\u752820\u6761<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/&#8221; target=&#8221;_blank&#8221;&gt;phpcms\u5982\u4f55\u8c03\u53d6\u6700\u8fd1\u66f4\u65b0\u7684\u6587\u7ae0\uff1f phpcms v9\u8c03\u7528\u5168\u7ad9\u6700\u65b0\u6587\u7ae0\uff08\u6700\u8fd1\u66f4\u65b0\u6240\u6709\u5185\u5bb9\uff09 \u7b2c\u4e00\u6b65 \u4fee\u6539 phpcmsmodulescontentclasses&nbsp; content_tag.class.php&nbsp; \u5728\u6700\u540e\u9762\u7684 } \u4e0a\u9762\u6dfb\u52a0 public&nbsp;function&nbsp;newcontent($data){ $num&nbsp;=&nbsp;intval($data[&#8216;limit&#8217;])&nbsp;?&nbsp;intval($data[&#8216;limit&#8217;])&nbsp;:&nbsp;&#8217;20&#8217;; \/\/&nbsp;\u8bbe\u7f6e\u6392\u5e8f switch($data[&#8216;order&#8217;]){ case&nbsp;&#8216;1&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`id`&nbsp;ASC&nbsp;&#8216;; break; case&nbsp;&#8216;2&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`id`&nbsp;DESC&nbsp;&#8216;; break; case&nbsp;&#8216;3&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`inputtime`&nbsp;ASC&nbsp;&#8216;; break; case&nbsp;&#8216;4&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`inputtime`&nbsp;DESC&nbsp;&#8216;; break; case&nbsp;&#8216;5&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`updatetime`&nbsp;ASC&nbsp;&#8216;; break; case&nbsp;&#8216;6&#8217;: $order&nbsp;=&nbsp;&#8216;&nbsp;`updatetime`&nbsp;DESC&nbsp;&#8216;; break; default: $order&nbsp;=&nbsp;&#8216;&nbsp;`id`&nbsp;DESC&nbsp;&#8216;; } if($data[&#8216;catid&#8217;]){ $catids&nbsp;=&nbsp;explode(&#8216;,&#8217;,&nbsp;$data[&#8216;catid&#8217;]); foreach($catids&nbsp;as&nbsp;$catid){ $catid&nbsp;=&nbsp;intval($catid); if(empty($catid))continue; $this-&amp;gt;set_modelid($catid); $where&nbsp;=&nbsp;$this-&amp;gt;category[$catid][&#8216;child&#8217;]&nbsp;?&nbsp;&#8216;&nbsp;`catid`&nbsp;IN&nbsp;(&#8216;.$this-&amp;gt;category[$catid][&#8216;arrchildid&#8217;].&#8217;)&#8217;&nbsp;:&nbsp;&#8221;&nbsp;`catid`&nbsp;=&nbsp;$catid&#8221;; $datas&nbsp;=&nbsp;$this-&amp;gt;db-&amp;gt;select($where,&nbsp;&#8216;*&#8217;,&nbsp;$num,&nbsp;$order); $data[$catid][&#8216;data&#8217;]&nbsp;=&nbsp;$datas; \/\/&nbsp;\u8bb0\u5f55\u672c\u6b21\u7684\u6587\u7ae0\u6570 $data[&#8216;num&#8217;][]&nbsp;=&nbsp;count($datas); $model_num++; } }else{ $models&nbsp;=&nbsp;getcache(&#8216;model&#8217;,&nbsp;&#8216;commons&#8217;); foreach($models&nbsp;as&nbsp;$model){ $this-&amp;gt;db-&amp;gt;set_model($model[&#8216;modelid&#8217;]); $datas&nbsp;=&nbsp;$this-&amp;gt;db-&amp;gt;select(&#8221;,&nbsp;&#8216;*&#8217;,&nbsp;$num,&nbsp;$order); $data[$model[&#8216;modelid&#8217;]][&#8216;data&#8217;]&nbsp;=&nbsp;$datas; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-31464","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31464","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=31464"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31464\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}