emlog 文章页加入新的参数并写入数据库
2024/10/28 18:10:33 懒猫导航网 已浏览7次给emlog博客程序加入新的字段,方法很简单的,下面一步一步来实现手动加字段,首先在数据表emlog_blog中加入新的字段“emlog01”,参数中的“emlog01”可以自行修改,一定要统一,否则无效。
第一步:在admin/views/add_log.php对应的位置加入你要的参数代码,例如:
<div style="clear:both;">参数一:<input type="text" value="" name="emlog01" id="emlog01" style="width:750px;" /></div>
第二步:在admin/views/edit_log.php中对应的位置也加入你要的参数代码,例如:
<div style="clear:both;">参数一:<input type="text" value="<?php echo $emlog01;?>" name="emlog01" id="emlog01" style="width:750px;" /></div>
第三步:在admin/save_log.php中
管理员已设置登录后刷新可查看
第四步:在include/model/log_model.php中,没有这一步前台将无法显示
管理员已设置登录后刷新可查看
前台直接调用:<?php echo $emlog01;?>
以上步骤全部完成就可以实现添加参数了,不过美中不足的是只有点击《保存并返回》才能保存。如果想实现点击《保存》也能实现保存的话,请按下面的方法,admin/views/js/common.js中找到
editorMap['content'].sync();
editorMap['excerpt'].sync();
var url = "save_log.php?action=autosave";
var title = $.trim($("#title").val());
var alias = $.trim($("#alias").val());
var sort = $.trim($("#sort").val());
var postdate = $.trim($("#postdate").val());
var date = $.trim($("#date").val());
var logid = $("#as_logid").val();
var author = $("#author").val();
var content = $('#content').val();
var excerpt = $('#excerpt').val();
var tag = $.trim($("#tag").val());
var top = $("#post_options #top").attr("checked") == 'checked' ? 'y' : 'n';
var sortop = $("#post_options #sortop").attr("checked") == 'checked' ? 'y' : 'n';
var allow_remark = $("#post_options #allow_remark").attr("checked") == 'checked' ? 'y' : 'n';
var allow_tb = $("#post_options #allow_tb").attr("checked") == 'checked' ? 'y' : 'n';
var password = $.trim($("#password").val());
var ishide = $.trim($("#ishide").val());
var token = $.trim($("#token").val());
var ishide = ishide == "" ? "y" : ishide;
var querystr = "content="+enpreURIComponent(content)
+"&excerpt="+enpreURIComponent(excerpt)
+"&title="+enpreURIComponent(title)
+"&alias="+enpreURIComponent(alias)
+"&author="+author
+"&sort="+sort
+"&postdate="+postdate
+"&date="+date
+"&tag="+enpreURIComponent(tag)
+"&top="+top
+"&sortop="+sortop
+"&allow_remark="+allow_remark
+"&allow_tb="+allow_tb
+"&password="+password
+"&token="+token
+"&ishide="+ishide
+"&as_logid="+logid;
用下面的代码替换
editorMap['content'].sync();
editorMap['excerpt'].sync();
var url = "save_log.php?action=autosave";
var title = $.trim($("#title").val());
var alias = $.trim($("#alias").val());
var sort = $.trim($("#sort").val());
var postdate = $.trim($("#postdate").val());
var date = $.trim($("#date").val());
var logid = $("#as_logid").val();
var author = $("#author").val();
var content = $('#content').val();
var excerpt = $('#excerpt').val();
var tag = $.trim($("#tag").val());
var top = $("#post_options #top").attr("checked") == 'checked' ? 'y' : 'n';
var sortop = $("#post_options #sortop").attr("checked") == 'checked' ? 'y' : 'n';
var allow_remark = $("#post_options #allow_remark").attr("checked") == 'checked' ? 'y' : 'n';
var allow_tb = $("#post_options #allow_tb").attr("checked") == 'checked' ? 'y' : 'n';
var password = $.trim($("#password").val());
var emlog01 = $.trim($("#emlog01").val()); //新加代码
var ishide = $.trim($("#ishide").val());
var token = $.trim($("#token").val());
var ishide = ishide == "" ? "y" : ishide;
var querystr = "content="+enpreURIComponent(content)
+"&excerpt="+enpreURIComponent(excerpt)
+"&title="+enpreURIComponent(title)
+"&alias="+enpreURIComponent(alias)
+"&author="+author
+"&sort="+sort
+"&postdate="+postdate
+"&date="+date
+"&tag="+enpreURIComponent(tag)
+"&top="+top
+"&sortop="+sortop
+"&allow_remark="+allow_remark
+"&allow_tb="+allow_tb
+"&password="+password
+"&emlog01="+emlog01 //新加代码
+"&token="+token
+"&ishide="+ishide
+"&as_logid="+logid;