initAjax: { url: "<?php echo zen_href_link(FILENAME_ADDON); ?> ", data: {module: "ajax_category_tree", key: "0", cPath: "<?php echo $_GET['cPath']; ?> "} }, children:<?php print getAjaxCategoryTreeJson($top); ?> , strings: { loading: "Loading…", loadError: "" }, onActivate: function(dtnode) { if(dtnode.data.key == "root") { value = "0"; } else { value = dtnode.data.key; } if (dtnode.data.url) {
function get_categories($parent_id = '0', $cPath = "") { global $db; // cPathの展開 if ($cPath != "") { $cPathArray = explode("_", $cPath); } else { $cPathArray = array(); } // get categories $categories_query = "select c.categories_id, cd.categories_name, c.categories_status\n from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd\n where\n parent_id = '" . (int) $parent_id . "'\n and c.categories_id = cd.categories_id\n and cd.language_id = '" . (int) $_SESSION['languages_id'] . "'\n and c.categories_status = 1\n order by sort_order, cd.categories_name"; $categories = $db->Execute($categories_query); while (!$categories->EOF) { // cPathが指定された場合の子供の展開 $child = array(); // 今処理しているカテゴリーと同じ場合に // その下層を検索する if (count($cPathArray) > 0 && $categories->fields['categories_id'] == $cPathArray[0]) { $parent_id = $cPathArray[0]; array_shift($cPathArray); $child = $this->get_categories($parent_id, implode("_", $cPathArray)); } $categories_ids = $this->getCategoryIdList($categories->fields['categories_id']); if (count($child)) { $childjson = ", children:" . getAjaxCategoryTreeJson($child); } else { $childjson = ""; } $categories_array[] = array('key' => $categories->fields['categories_id'], 'title' => $categories->fields['categories_name'], 'haschild' => zen_has_category_subcategories($categories->fields['categories_id']), 'url' => implode("_", $categories_ids), 'categoryid' => $categories->fields['categories_id'], 'child' => $child, 'childjson' => $childjson); $categories->MoveNext(); } return $categories_array; }