/** * 根据模板ID获得列表页子栏目 * * @access public * @param $tpl:模板id的值 * @return array */ function get_tpl_list_nav($tpl_id = '') { $lang = $GLOBALS['lang']; global $cateid; if (empty($tpl_id)) { $cate = $GLOBALS['cat_id']; } else { $tpl_id = intval($tpl_id); //获得栏目模板ID,不存在获取内容页的栏目模板ID $sql = "SELECT id from " . DB_PRE . "category WHERE lang='" . $lang . "' AND temp_id=" . $tpl_id; $cate_rel = $GLOBALS['mysql']->fetch_asc($sql); $cate = empty($cate_rel[0]['id']) ? $GLOBALS['cateid'] : $cate_rel[0]['id']; } //如果当前栏目没有下级,存在上级则返回上级 if (!empty($cate)) { if (file_exists(DATA_PATH . 'cache_cate/cache_category_all.php')) { include DATA_PATH . 'cache_cate/cache_category_all.php'; } $cate_info = get_cate_info($cate, $category); $child_num = $GLOBALS['mysql']->fetch_asc("select COUNT(id) as haschild from " . DB_PRE . "category where cate_parent=" . $cate); $cate = $child_num[0]['haschild'] ? $cate : $cate_info['cate_parent']; } if (!$cate) { return; } if (file_exists(DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php')) { include DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php'; } //当前语言下的栏目 $nav_arr = array(); if (!empty($cate_list)) { foreach ($cate_list as $k => $v) { if ($v['cate_parent'] == $cate && !$v['cate_hide']) { $channel_info = get_cate_info($v['cate_channel'], $GLOBALS['channel']); //获得栏目模型信息 $content_php = empty($channel_info['content_php']) ? 'show_content.php' : $channel_info['content_php']; $list_php = empty($channel_info['list_php']) ? 'show_list.php' : $channel_info['list_php']; $path = CMS_SELF; $nav_arr[$k]['target'] = intval($v['cate_is_open']) ? 'target="_blank"' : ''; //新窗口 if ($v['cate_tpl'] == 2) { $nav_arr[$k]['url'] = $v['cate_url']; } else { $nav_arr[$k]['url'] = $v['cate_html'] && $GLOBALS['_confing']['web_html'][0] ? $path . 'htm/' . $v['cate_fold_name'] : $path . $list_php . '?id=' . $v['id']; if ($v['cate_tpl'] == 3) { $nav_arr[$k]['url'] = $v['cate_html'] && $GLOBALS['_confing']['web_html'][0] ? $path . 'htm/' . $v['cate_fold_name'] . '/index.html' : $path . $list_php . '?id=' . $v['id']; } } //表单 if ($v['cate_channel'] == '-9') { $nav_arr[$k]['url'] = $v['cate_html'] && $GLOBALS['_confing']['web_html'][0] ? $path . 'htm/' . $v['cate_fold_name'] : $path . 'order/order.php?id=' . $v['id']; } if ($v['id'] == $cateid) { $nav_arr[$k]['class'] = "focus"; } $nav_arr[$k]['cate_name'] = $v['cate_name']; $nav_arr[$k]['cate_pic1'] = CMS_SELF . 'upload/' . $cate_info['cate_pic1']; $nav_arr[$k]['cate_pic2'] = CMS_SELF . 'upload/' . $cate_info['cate_pic2']; $nav_arr[$k]['cate_pic3'] = CMS_SELF . 'upload/' . $cate_info['cate_pic3']; $nav_arr[$k]['cate_content'] = $cate_info['cate_content']; $nav_arr[$k]['id'] = $v['id']; $nav_arr[$k]['cate_tpl'] = $v['cate_tpl']; $nav_arr[$k]['child'] = get_child_cate($v['id'], $GLOBALS['lang']); } } } if (!empty($nav_arr)) { $i = 1; $num = count($nav_arr); foreach ($nav_arr as $k => $v) { $nav_arr[$k]['autoindex'] = $i; $nav_arr[$k]['first'] = $i == 1 ? 1 : 0; $nav_arr[$k]['last'] = $num == $i ? 1 : 0; $i = $i + 1; } } return $nav_arr; }
function get_child_cate($parent_id, $lang, $cateid = '') { if (empty($parent_id)) { return; } $child = array(); $_confing = get_confing($lang); if (file_exists(DATA_PATH . 'cache_channel/cache_channel_all.php')) { include DATA_PATH . 'cache_channel/cache_channel_all.php'; } $sql = "select*from " . DB_PRE . "category where cate_parent=" . $parent_id . " order by cate_order asc"; $rel = $GLOBALS['mysql']->fetch_asc($sql); foreach ($rel as $row) { if (!$row['cate_hide']) { $channel_info = get_cate_info($row['cate_channel'], $GLOBALS['channel']); //获得内容模型信息 $list_php = empty($channel_info['list_php']) ? 'show_list.php' : $channel_info['list_php']; if ($row['cate_tpl'] == 2) { $url = $row['cate_url']; } else { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] : CMS_SELF . $list_php . '?id=' . $row['id']; if ($row['cate_tpl'] == 3) { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] . '/index_' . $lang . '.html' : CMS_SELF . $list_php . '?id=' . $row['id']; } } if ($row['cate_channel'] == '-9') { $url = $row['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $row['cate_fold_name'] : CMS_SELF . 'order/order.php?id=' . $row['id']; } if ($row['id'] == $GLOBALS['cat_id']) { $child[$row['id']]['class'] = "focus"; } $child[$row['id']]['url'] = $url; $child[$row['id']]['cate_name'] = $row['cate_name']; $child[$row['id']]['cate_pic1'] = CMS_SELF . 'upload/' . $row['cate_pic1']; $child[$row['id']]['cate_pic2'] = CMS_SELF . 'upload/' . $row['cate_pic2']; $child[$row['id']]['cate_pic3'] = CMS_SELF . 'upload/' . $row['cate_pic3']; $child[$row['id']]['cate_content'] = $row['cate_content']; $child[$row['id']]['cate_tpl'] = $row['cate_tpl']; if ($row['cate_parent'] != 0) { $child[$row['id']]['child'] = get_child_cate($row['id'], $lang); } } } return $child; }