类描述
类方法
列表分页演示
'接收参数 page = wts.valid.IntNum(wts.requests.querystr("page"), 1, 500, "") '调用模型 Set mHello = loader.LoadModel("Hello") Set rs = mHello.GetAll() '获取数据集合 Set oPage = loader.LoadClass("PageList") '调用分页对象 oPage.tempdata = wts.site.tempdata '用全局临时数据存储器取代默认临时数据存储器 oPage.CurrentPage = page '设置当前页 oPage.MaxPerPage = 5 '设置每页显示条数 n = oPage.List("news", rs) '将数据集合导入分页对象,并返回当前页集合条数 If n = 0 Then wts.errs.AddMsg "no page" wts.errs.Out 404 Else '遍历将链接等将后生成数据更新到分页集合中 For i = 0 To n link_str = "index.asp?route=hello/detail&id="&wts.template.GetVali("news/id", i) wts.template.setVali "news/link", i, wts.route.ReWrite(wts.site.config("base_url"), link_str) ' link_str = "index.asp?route=hello/edit&id="&wts.template.GetVali("news/id", i) wts.template.setVali "news/link_edit", i, wts.route.ReWrite(wts.site.config("base_url"), link_str) ' link_str = "index.asp?route=hello/del&id="&wts.template.GetVali("news/id", i) wts.template.setVali "news/link_del", i, wts.route.ReWrite(wts.site.config("base_url"), link_str) ' link_img = wts.route("pic").ReWritePic(wts.site.config("base_pic_url"), "image/no.gif", 50, 50, "") wts.template.setVali "news/pic", i, link_img ' wts.template.setVali "news/time", i, wts.fun.FormatDate(wts.template.GetVali("news/times", i),1) Next '生成分页"news_page" oPage.Plist wts.route,wts.site.config("base_url"),"index.asp?route=hello/list" End If Set oPage = Nothing rs.Close Set rs = Nothing Set mHello = Nothing '添加链接 wts.template.setVal "tag_addlink", wts.route.ReWrite(wts.site.config("base_url"), "index.asp?route=hello/add") '设置标题 wts.template.SetVal "title","WTS列表,翻页演示" '渲染模板 moban = wts.template.Fetch("hello_list.htm") '输出内容 wts.responses.SetOutput moban
详情页演示
'接收参数 id = wts.valid.IntNum(wts.requests.querystr("id"), 0, 0, "") wts.template.SetVal "tag_id", id '调用模型 Set mHello = loader.LoadModel("hello") Set rs = mHello.GetNameById(id) If rs.recordcount>0 Then wts.template.SetVal "tag_name", rs("name") wts.template.SetVal "title",rs("name") 'meta wts.template.SetVal "meta/name","description" wts.template.SetVal "meta/content",rs("name") wts.template.UpdVal "meta" Else wts.template.SetVal "tag_name", "no name" End If rs.Close Set rs = Nothing Set mHello = Nothing '渲染模板 moban = wts.template.Fetch("hello_detail.htm") '输出内容 wts.responses.SetOutput moban |