修正获取别名导致的错误

This commit is contained in:
liyukun 2022-04-10 10:30:23 +08:00
parent effc8926e9
commit 01785b105e
4 changed files with 29 additions and 27 deletions

View File

@ -132,7 +132,7 @@ class Ape extends TagLib
*/ */
public function tagList($tag, $content) public function tagList($tag, $content)
{ {
$orderBy = isset($tag['orderBy']) ? $tag['orderBy'] : 'sort asc,create_time desc'; $orderBy = isset($tag['orderBy']) ? $tag['orderBy'] : 'sort desc,create_time desc';
$pageSize = isset($tag['pageSize']) ? $tag['pageSize'] : 15; $pageSize = isset($tag['pageSize']) ? $tag['pageSize'] : 15;
$type = isset($tag['type']) ? $tag['type'] : 'find'; $type = isset($tag['type']) ? $tag['type'] : 'find';
$typeId = isset($tag['typeId']) ? $tag['typeId'] : '$cid'; $typeId = isset($tag['typeId']) ? $tag['typeId'] : '$cid';

View File

@ -40,7 +40,6 @@ class Article extends Base
$id = input('id/d'); $id = input('id/d');
//栏目分类标识 //栏目分类标识
$name = input('name'); $name = input('name');
if ($id) { if ($id) {
//获取分类信息 //获取分类信息
$dc = get_document_category($id); $dc = get_document_category($id);
@ -55,8 +54,7 @@ class Article extends Base
$id = $dc['id']; $id = $dc['id'];
$documentCategoryModel = new DocumentCategory(); $documentCategoryModel = new DocumentCategory();
//栏目存在 增加访问量 //栏目存在 增加访问量
$documentCategoryModel->where('id', $id)->inc('view')->update(); $documentCategoryModel->where('id|alias', $id)->inc('view')->update();
//判断后台统计配置是否开启 1 开启 //判断后台统计配置是否开启 1 开启
if (web_config("web_statistics") == 1) { if (web_config("web_statistics") == 1) {
//统计url //统计url
@ -120,7 +118,11 @@ class Article extends Base
} }
//获取该文章 //获取该文章
$documentModel = new Document(); $documentModel = new Document();
$article = $documentModel->where('status', 1)->where('id|alias', $id)->find(); if (is_int($id)){
$article = $documentModel->where('status', 1)->where('id', $id)->find();
}else{
$article = $documentModel->where('status', 1)->where('alias', $id)->find();
}
if (!$article) { if (!$article) {
$this->error('文章不存在或已删除!'); $this->error('文章不存在或已删除!');
} }
@ -133,7 +135,7 @@ class Article extends Base
//获取该文章内容 //获取该文章内容
//根据文章类型,加载不同的内容。 //根据文章类型,加载不同的内容。
$articleType = $article['type'] ? $article['type'] : 'article'; $articleType = $article['type'] ? $article['type'] : 'article';
$articleExt = $documentModel::name('document_' . $articleType)->where('id', $id)->find(); $articleExt = $documentModel::name('document_' . $articleType)->where('id', $article['id'])->find();
if (!$articleExt) { if (!$articleExt) {
$this->error('文章不存在或已删除!'); $this->error('文章不存在或已删除!');
} }

View File

@ -335,7 +335,7 @@ DROP TABLE IF EXISTS `ape_document_category`;
CREATE TABLE `ape_document_category` ( CREATE TABLE `ape_document_category` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题', `title` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标题',
`en_title` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标志', `alias` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '标志',
`icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类图标', `icon` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '分类图标',
`type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分类类别0列表1单篇2链接', `type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分类类别0列表1单篇2链接',
`pid` int(10) NOT NULL DEFAULT 0 COMMENT '上级分类ID', `pid` int(10) NOT NULL DEFAULT 0 COMMENT '上级分类ID',

View File

@ -76,26 +76,26 @@
<div class="index-tab-plane"> <div class="index-tab-plane">
<div class="index-tab-item index-tab-item-active" catid="0">最新文章</div> <div class="index-tab-item index-tab-item-active" catid="0">最新文章</div>
</div> </div>
<script> <!-- <script>-->
var nowid = $('.index-tab-item-active').attr('catid'); <!-- var nowid = $('.index-tab-item-active').attr('catid');-->
$('.index-tab-item').click(function () { <!-- $('.index-tab-item').click(function () {-->
if (nowid == $(this).attr('catid')) { <!-- if (nowid == $(this).attr('catid')) {-->
return; <!-- return;-->
} <!-- }-->
nowid = $(this).attr('catid'); <!-- nowid = $(this).attr('catid');-->
paged = 2; <!-- paged = 2;-->
$('.index-tab-item').removeClass('index-tab-item-active'); <!-- $('.index-tab-item').removeClass('index-tab-item-active');-->
$(this).addClass('index-tab-item-active'); <!-- $(this).addClass('index-tab-item-active');-->
$('.post-list').html('<div class="post-item post-loading"><i class="far fa-circle-notch fa-spin"></i> 加载中</div>'); <!-- $('.post-list').html('<div class="post-item post-loading"><i class="far fa-circle-notch fa-spin"></i> 加载中</div>');-->
$.post('/admin-ajax.php', { <!-- $.post('/admin-ajax.php', {-->
action: 'corepress_load_post_by_tabs', <!-- action: 'corepress_load_post_by_tabs',-->
cat: $(this).attr('catid') <!-- cat: $(this).attr('catid')-->
}, function (data) { <!-- }, function (data) {-->
$('.post-list').html(data); <!-- $('.post-list').html(data);-->
$("img").lazyload({effect: "fadeIn"}); <!-- $("img").lazyload({effect: "fadeIn"});-->
}) <!-- })-->
}); <!-- });-->
</script> <!-- </script>-->
</div> </div>
<ul class="post-list"> <ul class="post-list">
{ape:list orderby="create_time desc" pagesize="10" type="where" } {ape:list orderby="create_time desc" pagesize="10" type="where" }