当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 1

fotomxq / shenyuan-web
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
sort.php 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
fotomxq 提交于 2014-04-03 09:36 . 全局和栏目显示动态数量调整
<?php
/**
* 分类页面
* @author fotomxq <fotomxq.me>
* @version 3
* @package page
*/
require('page.php');
//初始化变量
$showType = 'none';
$sortRes = null;
$sortList = null;
$textList = null;
$pageStr = '';
if (isset($_GET['id']) == true) {
//页码模块
require(DIR_LIB . DS . 'page-pagination.php');
//获取上一级ID
$parent = (int) $_GET['id'];
//获取主体sort信息
$sortRes = $sysPost->get($parent, null, true);
//分类分页
//$sortPage = isset($_GET['page']) == true ? (int) $_GET['page'] : 1;
$sortPage = 1;
$sortMax = 999;
$sortSort = 3;
$sortDesc = false;
//获取分类列
$sortWhere = '`post_parent` = :parent and `post_status` = \'' . $sysPost->status[0] . '\' and `post_type` = \'' . $sysPost->type[0] . '\'';
$sortAttrs = array(':parent' => array($parent, PDO::PARAM_INT));
$sortList = $sysPost->getList($sortWhere, $sortAttrs, $sortPage, $sortMax, $sortSort, $sortDesc, true);
if ($sortList) {
$showType = 'sort';
$sortListRow = $sysPost->getListRow($sortWhere, $sortAttrs);
$url = 'sort.php?id=' . $parent . '&page=';
$pageStr = PagePaginationQuick($url, $sortPage, $sortListRow, $sortMax);
}
//文章分页
$textPage = 1;
//如果分类没有内容,则主体显示文章列,否则默认第一页为准
$textPage = isset($_GET['page']) == true ? (int) $_GET['page'] : 1;
$textMax = 10;
$textSort = 3;
$textDesc = false;
//获取文章列
$textWhere = '`post_status` = \'' . $sysPost->status[0] . '\' and `post_type` = \'' . $sysPost->type[2] . '\' and (`post_parent` = :parent';
if ($sortList) {
foreach ($sortList as $v) {
$textWhere .= ' or `post_parent` = ' . $v['id'];
}
$textSort = 0;
$textDesc = true;
}
$textWhere .= ')';
$textAttrs = array(':parent' => array($parent, PDO::PARAM_INT));
$textList = $sysPost->getList($textWhere, $textAttrs, $textPage, $textMax, $textSort, $textDesc);
if ($textList) {
$showType = 'text';
$textListRow = $sysPost->getListRow($textWhere, $textAttrs);
$url = 'sort.php?id=' . $parent . '&page=';
$pageStr = PagePaginationQuick($url, $textPage, $textListRow, $textMax);
//如果只有一篇,则判定为直接显示文本,跳转页面
if ($textListRow === 1) {
$url = 'text.php?id=' . $textList[0]['id'];
CoreHeader::toURL($url);
die();
}
}
//获取全网站最新消息
$textTopWhere = '`post_status` = \'' . $sysPost->status[0] . '\' and `post_type` = \'' . $sysPost->type[2] . '\'';
$textTopList = $sysPost->getList($textTopWhere, null, 1, 5, 0, true);
}
//注册变量
$smarty->assign('showType', $showType,true);
$smarty->assign('sortRes', $sortRes,true);
$smarty->assign('sortList', $sortList,true);
$smarty->assign('textList', $textList,true);
$smarty->assign('textPageNow', $textPage,true);
$smarty->assign('textPageMax', ceil($textListRow/$textMax),true);
$smarty->assign('pageStr', $pageStr,true);
$smarty->assign('textTopList', $textTopList);
//输出页面
$smarty->display('sort.tpl');
?>
PHP
1
https://gitee.com/fotomxq/shenyuan-web.git
git@gitee.com:fotomxq/shenyuan-web.git
fotomxq
shenyuan-web
shenyuan-web
master

搜索帮助