<?php
/**
* FILE_NAME : about.php
*
* @copyright Copyright (c) www.shuangyulin.com
* @author 双鱼林设计
* @package 前台单页面
* @subpackage
* @version QQ:287307421或254540457
*/

require_once './include/common.inc.php';

/*--  对一些系统变量赋值  --*/
$template->assign("css_root",$css_root);
$template->assign("siteurl",$_CFG['siteurl']);
$template->assign("sitename",$_CFG['sitename']);

/*--  初始化 url 传值  --*/
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 1;

/*--  查询单页数据  --*/
$sql = $allsin = '';
$sin = $cate = array();

$sql = "SELECT * FROM {$dbprefix}singlepage WHERE id = $id";
$sin = $DB->fetch_one_array($sql);
if (!$sin) {
	showmessage("找不到您查找的页面，请点击导航栏浏览！","index.php");
}

/*--  根据单页数据查询所属分类  --*/
$sql = "SELECT * FROM {$dbprefix}singlecategories WHERE catid = ".$sin['catid'];
$cate = $DB->fetch_one_array($sql);

/*--  根据分类 id 查询该分类下的所有文章  --*/
$sql = "SELECT id,title,url,target FROM {$dbprefix}singlepage WHERE catid = '".$cate['catid']."' ORDER BY displayorder";
$query = $DB->query($sql);
while ($row = $DB->fetch_array($query)) {
	$row['sysurl'] = "about.php?id=".$row['id'];
	$allsin[] = $row;
}

/*--  当单页的自定义模板为空，且不是外部链接，查询分类是否有自定义模板  --*/
$pagetpl = '';
if (!$sin['template'] && !$sin['url']) {	
	if (!$cate['template'] && !$cate['url']) {
		$pagetpl = "about.html";
	} elseif ($cate['url']) {
		$cateurl = '';
		$cateurl = $cate['url'];
		continue;
	} elseif ($cate['template']) {
	 	$pagetpl = $cate['template'];
	}
} elseif ($sin['url']) {
	$sinurl = $sin['url'];
	continue;
} elseif ($sin['template']) {
	$pagetpl = $sin['template']; 
}

require_once 'header.php';
 
/*--  对模板进行赋值  --*/
$template->assign("pagename",$sin['title']);
$template->assign("pageurl",$sinurl);
$template->assign("content",$sin['content']);
$template->assign("catename",$cate['name']);
$template->assign("allsin",$allsin);

$template->display($pagetpl);

require_once 'footer.php';
?>