帝国cms修改footer
编辑整理:整理来源:爱奇艺,浏览量:74,时间:2023-03-19 15:15:02
前沿:帝国cms修改footer
补充知识: 有些人在使用帝国CMS时,修改栏目路径后,你可以修改以前的文章的生成路径,可以一来自个个打开来修改,也可以直身击都曲接在数据库批量使用语句批量更新(也可以替换),最后重新生成即可!
是这样吗?我也不知道是对是温氢秋目盾财握减起含义错哦~~
角色管理的编辑和删除@extends('admin.common')@section('content')<button type="button" class="btn btn-primary" style="margin:10px auto;" onclick="onShowAdd()">添加</button> <table class="table table-hover table-bordered"> <thead> <tr> <th scope="col">ID</th> <th scope="col">角色名称</th> <th scope="col">操作</th> </tr> </thead> <tbody> @foreach ($roles as $k=>$v) <tr> <th scope="row">{{$v['id']}}</th> <td>{{$v['role_name']}}</td> <td> <button type="button" class="btn btn-outline-primary" onclick='editAdmin("{{route("role.detail",array("id"=>$v["id"]))}}")'>编辑</button> <button type="button" class="btn btn-outline-danger" onclick="deleteAdmin({{$v['id']}})">删除</button> </td> </tr> @endforeach </tbody> </table> <nav aria-label="Page navigation example"> <ul class="pagination justify-content-center"> @if($roles->currentPage()!=1) <li class="page-item"><a class="page-link" href="{{route('role.index').'?page=1'}}">首页</a></li> <li class="page-item"><a class="page-link" href="{{route('role.index').'?page='.($roles->currentPage()-1)}}">上一页</a></li> <li class="page-item"><a class="page-link" href="{{route('role.index').'?page='.($roles->currentPage()-1)}}"> {{$roles->currentPage()-1}}</a></li> @endif <li class="page-item"> <a class="page-link" href="{{route('role.index').'?page='.($roles->currentPage())}}" style="background:black;color:white"> {{$roles->currentPage()}} </a> </li> @if($roles->currentPage()!=$roles->lastPage()) <li class="page-item"><a class="page-link" href="{{route('role.index').'?page='.($roles->currentPage()+1)}}"> {{$roles->currentPage()+1}}</a> </li> <li class="page-item"><a class="page-link" href="{{route('role.index').'?page='.($roles->currentPage()+1)}}">下一页</a></li> <li class="page-item"><a class="page-link" href="{{route('role.index').'?page='.$roles->lastPage()}}">末页</a></li> @endif </ul> </nav> <!-- 添加弹框 --> <div class="modal fade" id="addModel" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">添加角色</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <div class="form-group"> <label for="rolename_id">角色名称</label> <input type="rolename" class="form-control" id="rolename_id"> <small id='rolename_err_id'></small> </div> <div class="form-group"> <label for="passwd_id">权限设置</label> <div class='check-container-cla'> @foreach ($menus as $k=>$v) <div class='check-mod'>{{$v['menuName']}}</div> @if($v['sub']) @foreach ($v['sub'] as $subk=>$subv) <div class='check-menu'>{{$subv['menuName']}}</div> @php $subs = explode(",",$subv['act']) @endphp <div class='act-container'> @foreach ($subs as $sk=>$sv) @php $acts = explode('_',$sv); @endphp <div class="form-check form-check-inline"> <input class="form-check-input" type="checkbox" value="{{$v['menuId'].'_'.$subv['menuId'].'_'.$acts[0]}}" id="check_{{$acts[0]}}"> <label class="form-check-label" for="check7_{{$acts[0]}}"> {{$acts[1]}} </label> </div> @endforeach </div> @endforeach @endif @endforeach </div> <small id='content_err_id'></small> </div> </div> <input type="hidden" id="role_id"> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button> <button id="submit_id" type="button" class="btn btn-primary">确定</button> </div> </div> </div> </div> <style> #content_err_id,#rolename_err_id{ color:red; } </style>@endsection@section('javascript') <script type="text/javascript"> var menus = {!! json_encode($menus,true) !!}; function onShowAdd(){ $('#addModel').modal('show'); $('#rolename_id').val(); $('#role_id').val(); } $('#submit_id').click(function(){ var checkedItems = $('.form-check-input'); var menuObj={}; for(var i=0;i<checkedItems.length;i++) { var item = checkedItems[i]; if(item.checked) { let valueArr = item.value.split('_'); var rightStr = ''; rightStr+=(valueArr.slice(0,valueArr.length-1)).join('_'); var value = valueArr[valueArr.length-1]; if(!menuObj[rightStr]) { menuObj[rightStr] = parseInt(value); }else{ menuObj[rightStr] += parseInt(value); } } } let content = ''; Object.keys(menuObj).forEach(item=>{ content+=item+'|'+menuObj[item]+',' }) var rolename = $('#rolename_id').val(); var roleId = $('#role_id').val(); var reqUrl = ''; var datas = {rolename,content,_token:"{{csrf_token()}}"}; if(!roleId) { // 是添加 reqUrl = "{{route('role.store')}}"; }else{ // 是更改 reqUrl = "{{route('role.update',['role'=>'my_id'])}}"; reqUrl = reqUrl.replace(/my_id/,roleId); datas._method ='put'; } datas = JSON.stringify(datas); $.ajax({ type:"post", url:reqUrl, data:datas, dataType:"json", contentType:"application/json", success:function(data){ $('#rolename_err_id').text(''); if(data.code == 200) { window.location.reload(); }else{ if(data.code==1000) { data.msg.rolename && $('#rolename_err_id').text(data.msg.rolename[0]); data.msg.content && $('#content_err_id').text(data.msg.content[0]); } } }, error:function(err){ } }); }); // 获取角色相关的信息 function editAdmin(url) { $('#addModel').modal('show'); $.ajax({ type:"get", url:url, dataType:"json", contentType:"application/json", success:function(data){ $('#rolename_err_id').text(''); $('#content_err_id').text(''); $('#role_id').val(); if(data.code == 200) { isChecked(data.info.right.content); $('#rolename_id').val(data.info.role_name); $('#role_id').val(data.info.id); }else{ } }, error:function(err){ } }); }; // 编辑时,设置是否选中 function isChecked(content) { // 按照逗号把权限内容进行分割 var contentArr = content.split(','); // 遍历权限数据,再按照|每个进行分割,并保存在一个obj中 var obj = {}; if(contentArr.length) { contentArr.forEach(item=>{ var itemArr = item.split('|'); if(itemArr[0]) { obj[itemArr[0]] = parseInt(itemArr[1]); } }) } // 开始查找弹框中的checkbox并依据value值进行与运算,以及上面得出的obj来判断是否有相应的权限,如果有的话,则需要设置选中状态 var checkedItems = $('.form-check-input'); for(var i=0;i<checkedItems.length;i++) { var checkItem = checkedItems[i]; var checkValue = checkItem.value; let valueArr = checkValue.split('_'); var rightStr = ''; rightStr+=(valueArr.slice(0,valueArr.length-1)).join('_'); var value = parseInt(valueArr[valueArr.length-1]); if(parseInt(obj[rightStr]&value) == parseInt(value)) { checkItem.checked = true; } } }; // 删除操作 function deleteAdmin(id) { var reqUrl = "{{route('role.destroy',['role'=>'my_id'])}}"; reqUrl = reqUrl.replace(/my_id/,id); $.ajax({ headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' }, type:"delete", url:reqUrl, dataType:"json", contentType:"application/json", success:function(data){ if(data.code == 200) { window.location.reload(); }else{ if(data.code==1000) { } } }, error:function(err){ } }); } </script> @endsection
RoleController.php更改
<?phpnamespace App\Http\Controllers\admin;use App\Http\Controllers\Controller;use Illuminate\Http\Request;use App\Models\Role;use App\Models\Right;use App\Http\Requests\RoleAddRequest;use Illuminate\Support\Facades\DB;class RoleController extends Controller{ /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $roles = Role::paginate(2,['id','role_name']); return view('admin.role',['roles'=>$roles]); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(RoleAddRequest $request) { // 开启事务 DB::beginTransaction(); try{ $role = new Role(); $right = new Right(); $role->role_name = $request->input('rolename'); $roleState = $role->save(); $right->role_id = $role->id; $right->content = $request->input('content'); $rightState = $right->save(); if($roleState && $rightState) { DB::commit(); return response()->json(['code'=>'200','msg'=>'添加成功']); }else{ DB::rollback(); } }catch(\Exception $e){ DB::rollback(); } return response()->json(['code'=>'1000','msg'=>'添加失败']); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(RoleAddRequest $request, $id) { // // 开启事务 DB::beginTransaction(); try{ $role = Role::find($id); $role->role_name = $request->input('rolename'); $roleState = $role->save(); $right = Right::where('role_id',$id)->first(); $right->content = $request->input('content'); $rightState = $right->save(); if($roleState && $rightState) { DB::commit(); return response()->json(['code'=>'200','msg'=>'添加成功']); }else{ DB::rollback(); } }catch(\Exception $e){ DB::rollback(); } return response()->json(['code'=>'1000','msg'=>'添加失败']); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // 这里有外键关联,所以,需要先删除对应的right表里对应此外键的数据,在删除role表下的此数据 DB::beginTransaction(); try{ $right = Right::where('role_id',$id)->first(); $rightState = $right->delete(); $roleState = Role::destroy($id); if($roleState && $rightState){ DB::commit(); return response()->json(['code'=>'200','msg'=>'删除成功']); } }catch(\Exception $e){ dd($e); DB::rollback(); } return response()->json(['code'=>'1000','msg'=>'删除失败']); } // 获取某个角色具体信息 public function detail($id){ $role = Role::where('id',$id)->with('right:content,role_id,id')->first(['id','role_name']); if($role) { return response()->json(['code'=>'200','info'=>$role]); }else{ return response()->json(['code'=>'1000','msg'=>'获取信息失败']); } }}
注:
看下以上的修改模板的弹框逻辑!
补充拓展:帝国cms修改footer
有图有真相,后台 - 模板 - 管理模板变量(红色框),然后修改右边页面头部(紫色框)。我给你的这个是帝国默认的头部同理,你可以自己调用,自己新增。
帝国默认的模板,导航是自动调用栏目名的,你要自己修改栏目。
如果你要修改首页中间部分注滑切英报密的话,就点击蓝色框首页模板修改,修改之后记得一定要刷新,点击数据更新,刷吧食帝你评广新首页就可以看到你防陈入统注话清府外修改的内容了。
看你的问题就知道你不会用CMS的,多去帝国论坛转转,自己多做几究础占次,开源的CMS只要会标签调用没有什么难的法。
行业热门话题:
【帝国CMS修改导航】【帝国CMS修改附件链接地址】【帝国cms更换编辑器】【帝国cms怎么用】【帝国cms使用手册】【帝国cms移动端设置教程】【帝国cms自定义页面】【帝国cms插件编写教程】【帝国cms转wordpress】【帝国cms刷新很慢】
帝国cms修改footer完!