Example #1
0
/**
 * 通过模板id取得当前栏目下的子栏目及其内容
 *
 * @access  public
 * @param   $id-添加的内容ID值,$tabel-模型表,$field-表中的字段
 * @return  array
 */
function get_all_cate_content($tpl_id = '', $content = 'no', $limit = '0,5', $order_type = 'id', $filter = '', $pic = 'no', $order = 'desc', $lang = '')
{
    $tpl_id = empty($tpl_id) ? '' : intval($tpl_id);
    //获得栏目模板ID,不存在获取内容页的栏目模板ID
    $lang = empty($lang) ? $GLOBALS['lang'] : $lang;
    if (empty($tpl_id)) {
        return;
    }
    //提前载入栏目和模型缓存,方便使用
    global $category, $channel;
    $_confing = get_confing($GLOBALS['lang']);
    $sql = "SELECT id from " . DB_PRE . "category WHERE lang='" . $lang . "' AND temp_id=" . $tpl_id;
    $cate_rel = $GLOBALS['mysql']->fetch_asc($sql);
    $parent = $cate_rel[0]['id'];
    unset($cate_rel);
    if (empty($parent)) {
        return;
    }
    $sql = "SELECT id,cate_tpl,cate_is_open,cate_html,cate_name,cate_title_seo,cate_channel,cate_fold_name,cate_url,cate_pic1,cate_pic2,cate_pic3,cate_content from " . DB_PRE . "category WHERE lang='" . $lang . "' and cate_hide=0 and cate_channel != -9 AND cate_channel != 1 AND cate_parent=" . $parent;
    $cate_rel = $GLOBALS['mysql']->fetch_asc($sql);
    $return_arr = array();
    $cate_arr = array();
    $cate_loop = array();
    if (!empty($cate_rel)) {
        foreach ($cate_rel as $c_v) {
            $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'];
            if ($v['cate_tpl'] == 2) {
                $cate_url = $c_v['cate_url'];
            } else {
                $cate_url = $c_v['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $c_v['cate_fold_name'] : $path . $list_php . '?id=' . $c_v['id'];
                if ($c_v['cate_tpl'] == 3) {
                    $cate_url = $c_v['cate_html'] && $_confing['web_html'][0] ? CMS_SELF . 'htm/' . $c_v['cate_fold_name'] . '/index.html' : $path . $list_php . '?id=' . $c_v['id'];
                }
            }
            $cate_arr['cate_name'] = $c_v['cate_name'];
            //栏目名称
            $cate_arr['cate_url'] = $cate_url;
            //栏目地址
            $cate_arr['target'] = intval($c_v['cate_is_open']) ? 'target="_blank"' : '';
            //是否新窗口
            $cate_arr['cate_pic1'] = empty($c_v['cate_pic1']) ? '' : CMS_SELF . 'upload/' . $c_v['cate_pic1'];
            $cate_arr['cate_pic2'] = empty($c_v['cate_pic2']) ? '' : CMS_SELF . 'upload/' . $c_v['cate_pic2'];
            $cate_arr['cate_pic3'] = empty($c_v['cate_pic3']) ? '' : CMS_SELF . 'upload/' . $c_v['cate_pic3'];
            $cate_arr['cate_content'] = $c_v['cate_content'];
            //获取内容
            if ($content == 'yes') {
                $cate_loop = get_cate_content($c_v['id'], $limit, $order_type, $filter, $pic, $order, $lang);
            }
            $return_arr[$c_v['id']]['cate'] = $cate_arr;
            $return_arr[$c_v['id']]['contents'] = $cate_loop;
        }
    }
    return $return_arr;
}
Example #2
0
}
define('CMS', true);
require_once '../includes/init.php';
require_once '../includes/fun.php';
require_once '../includes/lib.php';
$action = isset($_REQUEST['action']) ? trim($_REQUEST['action']) : 'book';
$lang = isset($_REQUEST['lang']) ? htmlspecialchars(fl_value($_REQUEST['lang'])) : get_main_lang();
if (file_exists(LANG_PATH . 'lang_' . $lang . '.php')) {
    include LANG_PATH . 'lang_' . $lang . '.php';
}
//语言包缓存,数组$language
if (file_exists(DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php')) {
    include DATA_PATH . 'cache_cate/cate_list_' . $lang . '.php';
}
//当前语言下的栏目
$_confing = get_confing($lang);
$tpl->template_dir = TP_PATH . $_confing['web_template'] . '/';
//模板路径
$tpl->template_lang = $lang;
//语言
$tpl->template_is_cache = 0;
//缓存
$tpl->assign('lang', $lang);
$book_focus = 'focus';
//留言页
if ($action == 'book') {
    $pr_id = intval($_GET['pr_id']);
    if (!empty($pr_id)) {
        $arc_rel = $mysql->fetch_asc("select title from " . DB_PRE . "maintb where id=" . $pr_id);
        $arc_title = $arc_rel[0]['title'];
    }
Example #3
0
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;
}