{"id":60923,"date":"2025-04-26T10:51:41","date_gmt":"2025-04-26T02:51:41","guid":{"rendered":"https:\/\/fwq.ai\/blog\/60923\/"},"modified":"2025-04-26T10:51:41","modified_gmt":"2025-04-26T02:51:41","slug":"zencart%e6%96%b0%e5%a2%9ecategories%e5%88%86%e7%b1%bb%e8%a1%a8%e5%ad%97%e6%ae%b5%e6%ad%a5%e9%aa%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/60923\/","title":{"rendered":"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4"},"content":{"rendered":"<p> zencart\u65b0\u589e\u5206\u7c7b\u5b57\u6bb5\u6b65\u9aa4<\/p>\n<p> 1.categories\u8868\u65b0\u589e\u5b57\u6bb5related_categories\u3001related_products<\/p>\n<pre>\r\nALTER TABLE `categories` ADD `related_categories` VARCHAR( 255 ) NOT NULL , ADD `related_products` VARCHAR( 255 ) NOT NULL;<\/pre>\n<p> 2.\u4fee\u6539admin\\categories.php<\/p>\n<p> \u5927\u6982212\u884c<\/p>\n<pre>\r\n$insert_sql_data = array('parent_id' =&gt; $current_category_id,\r\n                                 'date_added' =&gt; 'now()');<\/pre>\n<p> \u6539\u4e3a<\/p>\n<pre>\r\n$insert_sql_data = array('parent_id' =&gt; $current_category_id,\r\n                                 'date_added' =&gt; 'now()',\r\n                                 'related_categories'=&gt;$_POST['related_categories'],\r\n                                 'related_products'=&gt;$_POST['related_products']);<\/pre>\n<p> \u5927\u6982239\u884c<\/p>\n<pre>\r\n$update_sql_data = array('last_modified' =&gt; 'now()');<\/pre>\n<p> \u6539\u4e3a<\/p>\n<pre>\r\n$update_sql_data = array('last_modified' =&gt; 'now()','related_categories'=&gt;$_POST['related_categories'],'related_products'=&gt;$_POST['related_products']);<\/pre>\n<p> \u5927\u6982776\u884c<br \/> \u5728\u4ee3\u7801<\/p>\n<pre>\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;' . TEXT_CATEGORIES_DESCRIPTION . $category_inputs_string);<\/pre>\n<p> \u4e0b\u9762\u4e00\u884c\u65b0\u589e<\/p>\n<pre>\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;\u5173\u8054\u5206\u7c7bID\uff08ID\u4e4b\u95f4\u7528\u82f1\u6587\u534a\u89d2\u9017\u53f7\u9694\u5f00\uff09&lt;br \/&gt;' . zen_draw_input_field('related_categories', '', zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')));\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;\u5173\u8054\u4ea7\u54c1ID\uff08ID\u4e4b\u95f4\u7528\u82f1\u6587\u534a\u89d2\u9017\u53f7\u9694\u5f00\uff09&lt;br \/&gt;' . zen_draw_input_field('related_products', '', zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')));<\/pre>\n<p> \u5927\u6982834\u884c<br \/> \u5728\u4ee3\u7801<\/p>\n<pre>\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;' . TEXT_CATEGORIES_DESCRIPTION . $category_inputs_string);<\/pre>\n<p> \u4e0b\u9762\u4e00\u884c\u65b0\u589e<\/p>\n<pre>\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;\u5173\u8054\u5206\u7c7bID\uff08ID\u4e4b\u95f4\u7528\u82f1\u6587\u534a\u89d2\u9017\u53f7\u9694\u5f00\uff09&lt;br \/&gt;' . zen_draw_input_field('related_categories', zen_get_related_categories($cInfo-&gt;categories_id), zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')));\r\n$contents[] = array('text' =&gt; '&lt;br \/&gt;\u5173\u8054\u4ea7\u54c1ID\uff08ID\u4e4b\u95f4\u7528\u82f1\u6587\u534a\u89d2\u9017\u53f7\u9694\u5f00\uff09&lt;br \/&gt;' . zen_draw_input_field('related_products', zen_get_related_products($cInfo-&gt;categories_id), zen_set_field_length(TABLE_CATEGORIES_DESCRIPTION, 'categories_name')));<\/pre>\n<p> 3.admin\\includes\\functions\\extra_functions\\\u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6extra_functions.php<br \/> \u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/c160110\/14523AP141H0-29549.gif\" class=\"aligncenter\" title=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" alt=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" \/>  <\/p>\n<pre>\r\n&lt;?php\r\n\r\nfunction zen_get_related_categories($category_id) {\r\n    global $db;\r\n    $category = $db-&gt;Execute(\"select related_categories\r\n                              from \" . TABLE_CATEGORIES . \"\r\n                              where categories_id = '\" . (int)$category_id . \"'\");\r\n    return $category-&gt;fields['related_categories'];\r\n}\r\n\r\nfunction zen_get_related_products($category_id) {\r\n    global $db;\r\n    $category = $db-&gt;Execute(\"select related_products\r\n                              from \" . TABLE_CATEGORIES . \"\r\n                              where categories_id = '\" . (int)$category_id . \"'\");\r\n    return $category-&gt;fields['related_products'];\r\n}  \r\n\r\n?&gt;<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/c160110\/14523AP141H0-29549.gif\" class=\"aligncenter\" title=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" alt=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" \/>   <\/p>\n<p> &nbsp;<\/p>\n<p> 4.\u524d\u53f0\u663e\u793a\u65b0\u589e\u5b57\u6bb5\uff0cincludes\\functions\\extra_functions\\\u76ee\u5f55\u4e0b\u65b0\u5efa\u6587\u4ef6extra_functions.php<\/p>\n<p> \u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/c160110\/14523AP141H0-29549.gif\" class=\"aligncenter\" title=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" alt=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" \/>  <\/p>\n<pre>\r\n&lt;?php\r\n\r\nfunction zen_get_related_categories($category_id) {\r\n    global $db;\r\n    $category = $db-&gt;Execute(\"select related_categories\r\n                              from \" . TABLE_CATEGORIES . \"\r\n                              where categories_id = '\" . (int)$category_id . \"'\");\r\n    return $category-&gt;fields['related_categories'];\r\n}\r\n\r\nfunction zen_get_related_products($category_id) {\r\n    global $db;\r\n    $category = $db-&gt;Execute(\"select related_products\r\n                              from \" . TABLE_CATEGORIES . \"\r\n                              where categories_id = '\" . (int)$category_id . \"'\");\r\n    return $category-&gt;fields['related_products'];\r\n}  \r\n\r\n?&gt;<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/www.ldhost.cn\/helphmb\/uploads\/allimg\/c160110\/14523AP141H0-29549.gif\" class=\"aligncenter\" title=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" alt=\"zencart\u65b0\u589ecategories\u5206\u7c7b\u8868\u5b57\u6bb5\u6b65\u9aa4\u63d2\u56fe\" \/>   <\/p>\n<p> \u63a5\u7740\uff0c\u5728\u524d\u53f0\u9875\u9762tpl_index_categories.php\u3001tpl_index_product_list.php\u91cc\u9762\u9002\u5f53\u4f4d\u7f6e\u8c03\u7528\u65b0\u589e\u5b57\u6bb5\u503c<\/p>\n<pre>\r\necho zen_get_related_categories($current_category_id);\r\necho zen_get_related_products($current_category_id);<\/pre>\n<p> \u6253\u5b8c\u6536\u5de5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>zencart\u65b0\u589e\u5206\u7c7b\u5b57\u6bb5\u6b65\u9aa4 1.categories\u8868\u65b0\u589e\u5b57\u6bb5related_categories\u3001related_products ALTER TABLE `categories` ADD `related_categories` VARCHAR( 255 ) NOT NULL , ADD `related_products` VARCHAR( 255 ) NOT NULL; 2.\u4fee\u6539admin\\categories.php \u5927\u6982212\u884c $insert_sql_data = array(&#8216;parent_id&#8217; =&gt; $current_category_id, &#8216;date_added&#8217; =&gt; &#8216;now()&#8217;); \u6539\u4e3a $insert_sql_data = array(&#8216;parent_id&#8217; =&gt; $current_category_id, &#8216;date_added&#8217; =&gt; &#8216;now()&#8217;, &#8216;related_categories&#8217;=&gt;$_POST[&#8216;related_categories&#8217;], &#8216;related_products&#8217;=&gt;$_POST[&#8216;related_products&#8217;]); \u5927\u6982239\u884c $update_sql_data = array(&#8216;last_modified&#8217; =&gt; &#8216;now()&#8217;); \u6539\u4e3a $update_sql_data = array(&#8216;last_modified&#8217; =&gt; &#8216;now()&#8217;,&#8217;related_categories&#8217;=&gt;$_POST[&#8216;related_categories&#8217;],&#8217;related_products&#8217;=&gt;$_POST[&#8216;related_products&#8217;]); \u5927\u6982776\u884c \u5728\u4ee3\u7801 [&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-60923","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60923","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=60923"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/60923\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=60923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=60923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=60923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}