一个政府网站维护内容的实例,添加信息
信息编辑页面
主题、顺序及栏目节点
<table border="0" cellpadding="0" cellspacing="0" align="center" width="96%">
<tr height="30">
<td> 主 题</td>
<td><input name="SUBJECT" size="98"></td>
</tr>
<chtml><esql module=base id=count>Select max(WE_SORT) as max1 from SITE_NEWS where CLASSIFY=@{pPage:only}</esql></chtml>
<tr height="30">
<td> 顺 序</td>
<td><input name="we_sort" size="8" value="@{int:@{count:max1}+1}"></td>
</tr>
<tr>
<td> </td>
<td></td>
</tr><input type="hidden" value="@{pPage:only}" name="only"><input type="hidden" value="@{pPage:n}" name="n">
</table>
引入编辑器(老版,现在已经不在使用,新编辑器请参照
上一篇)
<table border="0" cellpadding="0" cellspacing="0" width="96%" align="center">
<textarea name="BODY" style="display:none"></textarea>
<tr>
<td>
<chtml file="help/editor/edit.html"/>
</td>
</tr>
</table>
完整的编辑表单代码(上两部分加起来)
<br><!-- 信息表单 -->
<form id=save action="add_save.chtml" method="post">
<table border="0" cellpadding="0" cellspacing="0" align="center" width="96%">
<tr height="30">
<td> 主 题</td>
<td><input name="SUBJECT" size="98"></td>
</tr>
<chtml><esql module=base id=count>Select max(WE_SORT) as max1 from SITE_NEWS where CLASSIFY=@{pPage:only}</esql></chtml>
<tr height="30">
<td> 顺 序</td>
<td><input name="we_sort" size="8" value="@{int:@{count:max1}+1}"></td>
</tr>
<tr>
<td> </td>
<td></td>
</tr><input type="hidden" value="@{pPage:only}" name="only"><input type="hidden" value="@{pPage:n}" name="n">
</table>
<table border="0" cellpadding="0" cellspacing="0" width="96%" align="center">
<textarea name="BODY" style="display:none"></textarea>
<tr>
<td>
<chtml file="help/editor/edit.html"/>
</td>
</tr>
</table>
</form>
提交的脚本
function doSubmit()
{
var saves = document.forms['save'];
if(saves['SUBJECT'].value=="")
{alert("主题不能空!");saves['SUBJECT'].focus();return;}
saves['BODY'].value=GetHtml();
if(saves['BODY'].value=="")
{alert("内容不能空!");GetCompFocus();return;}
saves.submit();
}
信息保存的页面
判断编辑权限
<chtml><Bag id=sys><we name=NodeID>c0.4.0</we></Bag></chtml><!-- 栏目节点 -->
<chtml file="base/ac/checkAcl.htm"/><!-- 引入权限检查文件 -->
<chtml>
<!-- 权限判断 -->
<if x="@{sys:canDo}" else=1>
<we x=true>
......
</we>
<script>alert("您没有权限!");history.back();</script>
</if>
</chtml>
修正显示顺序
<esql module=base id=count>select min(we_sort) as min1 from site_news where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql>
<if x="@{pPage:we_sort}">
<esql x="@{count:min1}" module=base act=edit>update site_news set we_sort=we_sort+1 where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql>
</if>
插入记录
<ESql module=dc act=edit>
Insert Into SITE_NEWS(SUBJECT,we_sort,CLASSIFY,AUTHOR,ONDATE,BODY
)
Values( @{pPage:SUBJECT:string},'@{int:@{pPage:we_sort}+0}','@{pPage:only}','@{session:we_id}',@{sys:date:datetime},@{pPage:BODY:memo}
)
</ESql>
返回列表页
<script>
location.href='@{sys:face}@{sys:curPath}list.html?n=@{pPage:n}';
</script>
完整的网页代码
<html>
<chtml><Bag id=sys><we name=NodeID>c0.4.0</we></Bag></chtml><!-- 栏目节点 -->
<chtml file="base/ac/checkAcl.htm"/><!-- 引入权限检查文件 -->
<chtml>
<!-- 权限判断 -->
<if x="@{sys:canDo}" else=1>
<we x=true>
<esql module=base id=count>select min(we_sort) as min1 from site_news where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql>
<if x="@{pPage:we_sort}">
<esql x="@{count:min1}" module=base act=edit>update site_news set we_sort=we_sort+1 where we_sort>=@{pPage:we_sort} and classify='@{pPage:only}'</esql>
</if>
<ESql module=dc act=edit>
Insert Into SITE_NEWS(SUBJECT,we_sort,CLASSIFY,AUTHOR,ONDATE,BODY
)
Values( @{pPage:SUBJECT:string},'@{int:@{pPage:we_sort}+0}','@{pPage:only}','@{session:we_id}',@{sys:date:datetime},@{pPage:BODY:memo}
)
</ESql>
</we>
<script>alert("您没有权限!");history.back();</script>
</if>
</chtml>
<script>
location.href='@{sys:face}@{sys:curPath}list.html?n=@{pPage:n}';
</script>
</html>
跟上一篇比结构和代码内容都非常类似,只是SQL的语法换成了SQLServer,但应用场景却发生了根本变化,轻开平台的优势就是能轻松应对这种变化,很酷吧
轻开平台资源下载及说明
平台免费下载:http://download.csdn.net/detail/tx18/8381859
最新开发手册下载:http://download.csdn.net/detail/tx18/8411089
开发实例:轻开B2C电子商务网站,免费下载:http://download.csdn.net/detail/tx18/8318585
轻开平台会不定期升级为大家提供更多强大而Easy的功能,请留意最新的开发手册