tag和分类cate_id为空的提示

This commit is contained in:
taoser 2022-09-07 15:24:25 +08:00
parent a3b4b8e16c
commit 38d6f26b5a
11 changed files with 94 additions and 49 deletions

View File

@ -33,10 +33,17 @@ class BaseController extends BaseCtrl
$this->uid = Session::get('user_id'); $this->uid = Session::get('user_id');
//系统配置 //系统配置
$this->showSystem(); $this->showSystem();
//显示分类导航
$this->showNav(); //变量赋给模板
//用户 View::assign([
$this->showUser($this->uid); //显示分类导航
'cateList' => $this->showNav(),
//显示子分类导航
'subcatelist' => $this->showSubnav(),
//当前登录用户
'user' => $this->showUser($this->uid),
]);
} }
@ -56,18 +63,47 @@ class BaseController extends BaseCtrl
} }
} }
// 显示导航 // 显示导航nav
protected function showNav() protected function showNav()
{ {
//1.查询分类表获取所有分类 //1.查询分类表获取所有分类
$cateList = Db::name('cate')->where(['status'=>1,'delete_time'=>0])->order('sort','asc')->cache('catename',3600)->select()->toArray(); $cateList = Db::name('cate')->where(['status'=>1,'delete_time'=>0])->order(['id' => 'ASC','sort' => 'ASC'])->cache('catename',3600)->select()->toArray();
$cateList = array2tree($cateList); $cateList = array2tree($cateList);
// $cateList = getTree($cateList); // $cateList = getTree($cateList);
// dump($cateList);
//2.将catelist变量赋给模板 公共模板nav.html
View::assign('cateList',$cateList);
return $cateList; return $cateList;
}
// 显示子导航subnav
protected function showSubnav()
{
// dump($this->showNav());
//1.查询父分类id
$pCate = Db::name('cate')->field('id,pid,ename,catename,is_hot')->where(['ename'=>input('ename'),'status'=>1,'delete_time'=>0])->find();
if(empty($pCate)) { // 没有点击任何分类,点击首页获取全部分类信息
$subCateList = $this->showNav();
} else { // 点击分类,获取子分类信息
$parentId = $pCate['id'];
$subCate = Db::name('cate')->field('id,ename,catename,is_hot,pid')->where(['pid'=>$parentId,'status'=>1,'delete_time'=>0])->order(['id' => 'ASC','sort' => 'ASC'])->select()->toArray();
if(!empty($subCate)) { // 有子分类
$subCateList = array2tree($subCate);
} else { //无子分类
if($pCate['pid'] == 0) {
//一级菜单
$subCateList[] = $pCate;
} else {
//子菜单下如果无子菜单,则显示全部兄弟分类
$parament = Db::name('cate')->field('id,ename,catename,is_hot,pid')->where(['pid'=>$pCate['pid'],'status'=>1,'delete_time'=>0])->order(['sort' => 'asc'])->select()->toArray();
$subCateList = array2tree($parament);
}
}
}
return $subCateList;
} }
//显示当前登录用户 //显示当前登录用户
@ -79,9 +115,6 @@ class BaseController extends BaseCtrl
$user = Db::name('user')->field('id,name,nickname,user_img,sex,area_id,auth,city,email,active,sign,point,vip,create_time')->find($id); $user = Db::name('user')->field('id,name,nickname,user_img,sex,area_id,auth,city,email,active,sign,point,vip,create_time')->find($id);
Cache::tag('user')->set('user'.$id,$user,600); Cache::tag('user')->set('user'.$id,$user,600);
} }
//2.将User变量赋给模板 公共模板nav.html
View::assign('user',$user);
return $user; return $user;
} }

View File

@ -57,6 +57,8 @@ Route::group('art',function () use($detail_as,$cate_as){
Route::rule('tags','Article/tags')->allowCrossDomain(); Route::rule('tags','Article/tags')->allowCrossDomain();
Route::rule('edit/[:id]','Article/edit'); Route::rule('edit/[:id]','Article/edit');
Route::get('article/catetree','Article/getCateTree'); Route::get('article/catetree','Article/getCateTree');
Route::get('download/[:id]','Article/download');
}); });
//tag //tag

View File

@ -16,7 +16,7 @@ return [
// 应用名,此项不可更改 // 应用名,此项不可更改
'appname' => 'TaoLer', 'appname' => 'TaoLer',
// 版本配置 // 版本配置
'version' => '1.9.23', 'version' => '1.9.26',
// 加盐 // 加盐
'salt' => 'taoler', 'salt' => 'taoler',
// 数据库备份目录 // 数据库备份目录

View File

@ -180,8 +180,9 @@ pre{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border
/* 头部 */ /* 头部 */
.fly-header{position: fixed; left: 0; top: 0; z-index: 10000; width: 100%; height: 60px; border-bottom: 1px solid #404553; border-right: 1px solid #404553; border-radius: 0;} .fly-header{position: fixed; left: 0; top: 0; z-index: 10000; width: 100%; height: 60px; border-bottom: 1px solid #404553; border-right: 1px solid #404553; border-radius: 0;}
.fly-logo{position: absolute; left: 15px; top: 11px;} .fly-logo{position: absolute; left: 15px; top: 11px;}
.fly-logo-m{position: absolute; left:calc(50% - 45px); top: 11px;}
.fly-nav{margin-left: 200px;} .fly-nav{margin-left: 200px;}
.fly-nav a i{position: absolute; left: 25px; top: 0; padding-right: 10px; font-size: 26px;} .fly-nav a i{position: absolute; left: 15px; top: 0; padding-right: 10px; font-size: 22px;}
.fly-nav a .icon-shouye, .nav a .icon-shezhi{top: 2px;} .fly-nav a .icon-shouye, .nav a .icon-shezhi{top: 2px;}
.fly-nav-user{position: absolute; top: 0; right: 0;} .fly-nav-user{position: absolute; top: 0; right: 0;}
@ -191,7 +192,7 @@ pre{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border
.fly-nav-avatar .fly-badge-vip{position: relative; margin-left: 10px;} .fly-nav-avatar .fly-badge-vip{position: relative; margin-left: 10px;}
.fly-nav-user .layui-nav-child a i{position: relative; top: 2px; margin-right: 10px; font-size: 26px;} .fly-nav-user .layui-nav-child a i{position: relative; top: 2px; margin-right: 10px; font-size: 26px;}
.fly-nav-msg{position:absolute; top: 50%; left: -25px; height: 20px; line-height: 20px; margin-top: -10px; padding:0 6px; background-color: #FF7200; color: #fff; border-radius: 2px;} .fly-nav-msg{position:absolute; top: 50%; right: 5px; height: 20px; line-height: 20px; margin-top: -10px; padding:0 6px; background-color: #FF7200; color: #fff; border-radius: 2px;}
.fly-nav-msg:hover{color:#fff;} .fly-nav-msg:hover{color:#fff;}
.fly-header .layui-nav{padding: 0; background: none;} .fly-header .layui-nav{padding: 0; background: none;}
@ -216,6 +217,12 @@ pre{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border
.fly-layui-user .layui-nav-child{left: auto; right: 0; min-width: 0; width: 120px;} .fly-layui-user .layui-nav-child{left: auto; right: 0; min-width: 0; width: 120px;}
*/ */
/* 搜索 */
.fly-header .layui-nav .fly-search{display: inline-block; vertical-align: top; width: 50px; height: 50px; padding-top:20px;margin-right: 10px; text-align: center; cursor: pointer; font-size: 20px;}
.fly-header .layui-nav .fly-search .layui-icon{font-size: 20px;}
.fly-header .layui-nav .fly-search:hover{color: #5FB878;}
.fly-header .layui-nav .fly-layer-search input{height: 75px; line-height: 75px; width: 500px; padding: 0 15px; font-size: 20px; border: none 0; background: none;}
/* 底部 */ /* 底部 */
.fly-footer {margin: 50px 0 0; padding: 20px 0 30px; line-height: 30px; text-align: center; color: #737573; border-top: 1px solid #e2e2e2;} .fly-footer {margin: 50px 0 0; padding: 20px 0 30px; line-height: 30px; text-align: center; color: #737573; border-top: 1px solid #e2e2e2;}
@ -247,12 +254,6 @@ pre{position: relative; margin: 10px 0; padding: 15px; line-height: 20px; border
.fly-column-right .layui-btn{vertical-align: initial;} .fly-column-right .layui-btn{vertical-align: initial;}
.fly-column .layui-badge-dot{position: absolute; top: 50%; left: 50%; margin: -4px 0 0 20px;} .fly-column .layui-badge-dot{position: absolute; top: 50%; left: 50%; margin: -4px 0 0 20px;}
/* 搜索 */
.fly-search{display: inline-block; vertical-align: top; width: 50px; height: 50px; margin-right: 10px; text-align: center; cursor: pointer; font-size: 20px;}
.fly-search .layui-icon{font-size: 20px;}
.fly-search:hover{color: #5FB878;}
.fly-layer-search input{height: 75px; line-height: 75px; width: 500px; padding: 0 15px; font-size: 20px; border: none 0; background: none;}
/* 幻灯 */ /* 幻灯 */
.fly-topline{height: 195px;} .fly-topline{height: 195px;}
.fly-topline img{max-width: 100%;} .fly-topline img{max-width: 100%;}
@ -459,7 +460,6 @@ body .layui-edit-face .layui-layer-content{padding:0; background-color:#fff; co
.detail-assist{ .detail-assist{
position: fixed; position: fixed;
width: 35px; width: 35px;
height:185px;
right: calc(50% - 625px); right: calc(50% - 625px);
top: 200px; top: 200px;
margin: 0 auto; margin: 0 auto;

View File

@ -44,7 +44,13 @@
<div style="margin-top: 15px; font-size: 18px; font-weight: bold; color: rgb(130, 125, 125)">问题描述:</div> <div style="margin-top: 15px; font-size: 18px; font-weight: bold; color: rgb(130, 125, 125)">问题描述:</div>
<hr /> <hr />
<div class="detail-body-wenda photos" id="content">{$article.content|raw}</div> <div class="detail-body-wenda photos" id="content">{$article.content|raw}</div>
{if (($article.upzip !== '') || session('?user_name'))}
<div class="">
{notempty name="$article.upzip"}
<button type="button" class="layui-btn layui-btn-xs" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}: {$article.downloads}次</button>
{/notempty}
</div>
{/if}
<div style="margin-top: 25px">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div> <div style="margin-top: 25px">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
{notempty name="tags"} {notempty name="tags"}
<div style="margin-top: 15px">标签 <div style="margin-top: 15px">标签
@ -112,7 +118,7 @@
</div> </div>
<div style="margin: 5px 0px;"> <div style="margin: 5px 0px;">
<hr width="90%" style="border:1px dotted red;height:1px" /> <hr width="90%" style="border:1px dotted red;height:1px" />
<div style="padding: 10px 0px">{$vo.user.sign|raw}</div> <div>{$vo.user.sign|raw}</div>
</div> </div>
</li> </li>
{/volist} {/volist}

View File

@ -144,6 +144,7 @@
<script src="/static/xm-select.js"></script> <script src="/static/xm-select.js"></script>
<script> <script>
var cateId = "{$article.cate.id}"; var cateId = "{$article.cate.id}";
var artId = "{$article.id}";
// 分类选择 // 分类选择
$(function(){ $(function(){
//这里模拟ajax //这里模拟ajax
@ -152,7 +153,7 @@ $(function(){
// 渲染下拉树 // 渲染下拉树
xmSelect.render({ xmSelect.render({
el: '#CateId', el: '#CateId',
name: 'id', name: 'cate_id',
height: '250px', height: '250px',
layVerify: 'required', layVerify: 'required',
layVerType: 'tips', layVerType: 'tips',

View File

@ -32,6 +32,13 @@
<hr style="margin-bottom: 25px"> <hr style="margin-bottom: 25px">
{// 内容} {// 内容}
<div class="detail-body photos" style="font-size: 18px;line-height: 200%;" id="content">{$article.content|raw}</div> <div class="detail-body photos" style="font-size: 18px;line-height: 200%;" id="content">{$article.content|raw}</div>
{if (($article.upzip !== '') || session('?user_name'))}
<div class="">
{notempty name="$article.upzip"}
<button type="button" class="layui-btn layui-btn-xs" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}: {$article.downloads}次</button>
{/notempty}
</div>
{/if}
<div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div> <div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
{notempty name="tags"} {notempty name="tags"}
<div style="margin-top: 15px">标签 <div style="margin-top: 15px">标签

View File

@ -54,6 +54,14 @@
<hr> <hr>
{// 内容} {// 内容}
<div class="detail-body photos mce-content-body" id="content">{$article.content|raw}</div> <div class="detail-body photos mce-content-body" id="content">{$article.content|raw}</div>
{//下载}
{if (($article.upzip !== '') || session('?user_name'))}
<div class="">
{notempty name="$article.upzip"}
<button type="button" class="layui-btn layui-btn-xs" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}: {$article.downloads}次</button>
{/notempty}
</div>
{/if}
<div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div> <div style="margin-top: 25px;">本文链接:<a href="{$Request.domain}{$Request.url}">{$Request.domain}{$Request.url}</a></div>
{notempty name="tags"} {notempty name="tags"}
<div style="margin-top: 15px">标签 <div style="margin-top: 15px">标签
@ -115,7 +123,7 @@
</div> </div>
<div style="margin: 5px 0px;"> <div style="margin: 5px 0px;">
<hr width="90%" style="border:1px dotted red;height:1px" /> <hr width="90%" style="border:1px dotted red;height:1px" />
<div style="padding: 10px 0px">{$vo.user.sign|raw}</div> <div>{$vo.user.sign|raw}</div>
</div> </div>
</li> </li>
{/volist} {/volist}

View File

@ -1,31 +1,21 @@
<!--
* @Author: TaoLer <317927823@qq.com>
* @Date: 2021-12-06 16:04:51
* @LastEditTime: 2022-07-30 08:27:32
* @LastEditors: TaoLer
* @Description: 优化版
* @FilePath: \github\TaoLer\view\taoler\index\public\column.html
* Copyright (c) 2020~2022 https://www.aieok.com All rights reserved.
-->
<div class="fly-panel fly-column layui-hide-xs"> <div class="fly-panel fly-column layui-hide-xs">
<div class="layui-container"> <div class="layui-container">
<ul class="layui-clear"> <ul class="layui-clear">
<li class="layui-hide-xs {if ($Request.param.ename =='' && $Request.param.id =='')} layui-this {/if}" > <li class="layui-hide-xs {if ($Request.param.ename =='' && $Request.param.id =='')} layui-this {/if}" >
<a href="{$Request.domain}">{:lang('home page')}</a> <a href="{$Request.domain}">{:lang('home page')}</a>
</li> </li>
{volist name="cateList" id="cate"} {volist name="subcatelist" id="vo"}
<li {if condition="$cate.ename eq $Request.param.ename"} class="layui-this" {/if} > <li {if($vo.ename eq $Request.param.ename)} class="layui-this" {/if} >
<a href="{$Request.domain}{:url('cate',['ename' => $cate.ename])}">{:cookie('think_lang') == 'en-us' ? $cate.ename : $cate.catename}{if condition="$cate.is_hot eq 1"}<span class="layui-badge-dot"></span>{/if}</a> <a href="{$Request.domain}{:url('cate',['ename' => $vo.ename])}">{:cookie('think_lang') == 'en-us' ? $vo.ename : $vo.catename}{if($vo.is_hot eq 1)}<span class="layui-badge-dot"></span>{/if}</a>
</li> </li>
{/volist} {/volist}
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li> <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><span class="fly-mid"></span></li>
{if session('?user_id')} {if session('?user_id')}
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post')}">{:lang('my post')}</a></li> <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post')}">{:lang('my post')}</a></li>
<li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post#collection')}">{:lang('my collection')}</a></li> <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block"><a href="{:url('user/post#collection')}">{:lang('my collection')}</a></li>
{/if} {/if}
</ul> </ul>
<div class="fly-column-right layui-hide-xs"> <div class="fly-column-right layui-hide-xs">
<span class="fly-search" data-url="{:url('user_search')}"><i class="layui-icon">&#xe615;</i></span>
<a href="{:url('add_article',['cate'=>$Request.param.ename])}" class="layui-btn" id="add_post">{:lang('add post')}</a> <a href="{:url('add_article',['cate'=>$Request.param.ename])}" class="layui-btn" id="add_post">{:lang('add post')}</a>
</div> </div>
</div> </div>

View File

@ -1,9 +1,6 @@
{//管理帖子加精、置顶、编辑、删除模块} {//管理帖子加精、置顶、编辑、删除模块}
{if (($article.upzip !== '') || session('?user_name'))} {if (($article.upzip !== '') || session('?user_name'))}
<div class="detail-assist"> <div class="detail-assist">
{notempty name="$article.upzip"}
<button type="button" class="layui-btn layui-btn-xs" id="zip-download"><i class="layui-icon layui-icon-download-circle"></i>{:lang('download files')}: {$article.downloads}次</button>
{/notempty}
<div class="fly-admin-box" data-id="{$article.id}"> <div class="fly-admin-box" data-id="{$article.id}">
{if ($user.auth ?? '')} {if ($user.auth ?? '')}
{if($article.is_top == 0)} {if($article.is_top == 0)}

View File

@ -5,8 +5,8 @@
<div class="site-tree-mobile-top layui-hide"><i class="layui-icon layui-icon-spread-left"></i></div> <div class="site-tree-mobile-top layui-hide"><i class="layui-icon layui-icon-spread-left"></i></div>
<div class="site-mobile-shade-top"></div> <div class="site-mobile-shade-top"></div>
{//移动端LOGO} {//移动端LOGO}
<a class="fly-logo layui-hide-md layui-hide-sm" href="{$Request.domain}" style="padding-left:50%; margin-left:-60px;"><img src="{$Request.domain}{$sysInfo.m_logo}" style="height:37px;" alt="logo"></a> <a class="layui-hide-md layui-hide-sm" href="{$Request.domain}" ><img class="fly-logo-m" src="{$Request.domain}{$sysInfo.m_logo}" alt="logo"></a>
<ul class="layui-nav fly-nav layui-hide-xs"> <ul class="layui-nav fly-nav layui-hide-xs">
{//导航nav} {//导航nav}
{volist name="cateList" id="cate"} {volist name="cateList" id="cate"}
<li class="layui-nav-item {if($cate.ename eq $Request.param.ename)} layui-this {/if}" > <li class="layui-nav-item {if($cate.ename eq $Request.param.ename)} layui-this {/if}" >
@ -32,8 +32,9 @@
{//头部右栏} {//头部右栏}
<ul class="layui-nav fly-nav-user" msg-url="{:url('message/nums')}" readMsg-url="{:url('Message/read')}" userlogin="{:url('user_login')}"> <ul class="layui-nav fly-nav-user" msg-url="{:url('message/nums')}" readMsg-url="{:url('Message/read')}" userlogin="{:url('user_login')}">
{if session('?user_id')} <span class="fly-search layui-hide-xs" data-url="{:url('user_search')}"><i class="layui-icon">&#xe615;</i></span>
<!-- 登录 --> {if session('?user_id')}
<!-- 登录 -->
{if ($Request.action=='user')} {if ($Request.action=='user')}
<li class="layui-nav-item"><a href="{$Request.domain}">{:lang('home page')}</a></li> <li class="layui-nav-item"><a href="{$Request.domain}">{:lang('home page')}</a></li>
{/if} {/if}