ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
## 留言板标签 适用范围:全站任意地方均可使用 标签作用:用于用户提交留言和调取留言记录 #### 1、留言提交表单 ~~~ <form action="{pboot:msgaction}" method="post"> 联系人:<input type="text" name="contacts" > 手机:<input type="text" name="mobile" > 内容:<input type="text" name="content" > 验证码:<input type="text" name="checkcode" > <img title="点击刷新" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" /> <button type="submit">提交</button></form> ~~~ 表单提交方式为post,表单中提交的字段名称需要与后台自定义表单中添加的字段一致,否则会导致提交失败。 需要更多字段时请在后台自定义表单中新增留言表单字段,然后再在前台新增form字段. 标签说明: {pboot:msgaction} 为留言表单接收地址 {pboot:checkcode} 为验证码图片地址 ### pbootcms使用Ajax无刷新提交留言及表单 1.表单验证 ~~~ <form onsubmit="return submsg(this);">     联系人<input type="text" name="contacts" required id="contacts">     手 机<input type="text" name="mobile" required id="mobile">     内 容<textarea name="content" id="content"></textarea>     验证码<input type="text" name="checkcode" required id="checkcode">     <img title="点击刷新" src="{pboot:checkcode}" onclick="this.src='{pboot:checkcode}?'+Math.round(Math.random()*10);" />     <button type="submit">提交留言</button> </form> ~~~ 2、Ajax提交 ~~~ <script> //ajax提交留言,由于涉及到提交地址标签的解析,JS需要放在html文件中 function submsg(obj){   var url='{pboot:msgaction}'; //如果是自定义表单则使用地址{pboot:form fcode=*}   var contacts=$(obj).find("#contacts").val();   var mobile=$(obj).find("#mobile").val();   var content=$(obj).find("#content").val();   var checkcode=$(obj).find("#checkcode").val(); //此处加个判断,避免碰到刷留言   if (!$('[name="contacts"]').val()) {alert('姓名不能为空');returnfalse;   } // 判断在要写入数组前,(我也是小白一个 判断写的不好,还请大佬们指教)   $.ajax({     type: 'POST',     url: url,     dataType: 'json',     data: {         contacts: contacts,         mobile: mobile,         content: content,         checkcode: checkcode     },     success: function (response, status) {       if(response.code){          alert("谢谢您的反馈,我们会尽快联系您!");          $(obj)[0].reset();        }else{          alert(response.data);       }     },     error:function(xhr,status,error){       alert('返回数据异常!');     }   });   return false; } </script> ~~~ #### 2、留言记录列表 ~~~ {pboot:message num=*} <p>[message:contacts]</p> <p>[message:content]</p> {/pboot:message} ~~~ 调取的留言记录默认执行分页,使用内容列表的分页代码即可. 内容隐私,使用截取功能: \[message:mobile substr=1,3\]****\[message:mobile substr=8\] 输出效果:187****6563 控制参数: num=\* 数量,非必填,为调取的留言分页大小 page=\* 是否分页1或0,非必填,用于关闭分页 lg=\* 调取指定语言留言,非必填,设置all则所有语言,不添加该参数则默认为当前语言(V1.3.7+) #### 3、留言记录列表可用标签 |[message:n]|序号从0开始 |---|---| |[message:i]序号从1开始 |[message:contacts]|联系人| |[message:mobile]|手机| |[message:content]|内容| |[message:recontent]|回复内容| |[message:ip]|用户IP| |[message:os]|用户操作系统| |[message:bs]|用户浏览器| |[message:askdate]|留言时间| |[message:replydate]|回复时间| |[message:*]|自定义的其它字段|