PbootCMS网站后台添加标题时,自动ajax查询标题是否重复
PbootCMS后台功能增加,发布内容时,无论哪个模块,自动检测文章标题是否存在。
实现方法
一、html部分改造
文件路径:apps/admin/view/default/content/content.html
1.搜索【内容标题】,大致在195行,内容修改为:
<div class="layui-form-item"> <label class="layui-form-label">内容标题 <span class="layui-text-red">*</span></label> <div class="layui-input-inline" style="width:80%;"> <input type="text" name="title" id="title" required lay-verify="required" placeholder="请输入内容标题" class="layui-input"> </div> <div class="layui-form-mid layui-word-aux" id="email_msg">*</div> </div>
2.页面底部{include file='common/ueditor.html'}内容前增加如下代码:
<script> $(document).ready(function() { $("input").blur(function() { var $parent = $(this).parent(); $parent.find(".formtips").remove(); if ($(this).is("#title")) { var title = this.value; if (title == "") { $("#email_msg").html("<span class='reg-error' style='display: inline;'>标题不能为空!</span>") } else { $.ajax({ url:"{url./admin/Content/checktitle/}", data:{ "formcheck":'{$formcheck}', "mcode":{$get.mcode}, "title":title, }, type:"POST", dataType:"json", success:function (data) { if (data.data =="有重复") { $("#email_msg").html("<a style='color:red'>"+data.data+"</a>"); }else { $("#email_msg").html("<span style='color:#08a600'>"+data.data+"</span>") } } }) } } }); }); </script>
二、PHP部分改造
文件路径:apps/admin/controller/content/ContentController.php
页面中增加如下代码即可:
已有21人购买版权所有,付费文档禁止转载。
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
点赞 6
热门主题
相关阅读
- PbootCMS如何选择数据库,SQLite和MySQL如何选择?
- PbootCMS页面打开跳转404错误页面的排查及解决方法
- PbootCMS百度推广链接带bd_vid=xxx后无法访问的解决方法
- PbootCMS上一篇下一篇调用时间等字段的方法
- PbootCMS的数据库是哪个文件
- pboot如何设置描述的字数限制
- PbootCMS 判断当前栏目是否有子栏目
- 如何修改PbootCMS默认面包屑导航样式及自定义设置方法
- PbootCMS防木马挂马/入侵安全设置指南
- PbootCMS CMSname在什么地方设置(PbootCMS全局参数定义)
- PbootCMS网站后台otherbot爬行怎么屏蔽
- PbootCMS授权码信息在哪个文件内?