修正获取别名导致的错误

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)
{
$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;
$type = isset($tag['type']) ? $tag['type'] : 'find';
$typeId = isset($tag['typeId']) ? $tag['typeId'] : '$cid';

View File

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

View File

@ -335,7 +335,7 @@ DROP TABLE IF EXISTS `ape_document_category`;
CREATE TABLE `ape_document_category` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`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 '分类图标',
`type` tinyint(4) NOT NULL DEFAULT 0 COMMENT '分类类别0列表1单篇2链接',
`pid` int(10) NOT NULL DEFAULT 0 COMMENT '上级分类ID',

View File

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