/// <summary> /// 输出最终的html /// </summary> /// <param name="templateFileName"></param> /// <param name="tPath"></param> /// <param name="wid"></param> public void OutPutHtml(string templateFileName, int wid) { //注册一个自定义函数 this.Document.RegisterGlobalFunction(this.GetNewsUrl); //对VT模板里的config变量赋值 Model.wxcodeconfig wxconfig = tDal.GetModelByWid(wid, "/templates/index/" + templateFileName); //if (wxconfig == null || wxconfig.sitename.Trim() == "") //{1e2124dd04e11d01b9df2865f85944be // HttpContext.Current.Response.Write("请填写【微网站设置】相关信息"); //} //else if (wxconfig.wxstatus == 0) { HttpContext.Current.Response.Write("帐号已过期!请及时充值!"); } this.Document.Variables.SetValue("config", wxconfig); //获得幻灯片列表方法一:缺点无法从模版页面控制记录数量 this.Document.Variables.SetValue("photo", tDal.GetHDPByWid(wid, -1)); this.Document.SetValue("wid", wid); this.Document.SetValue("bottomtype", wxconfig.bmenuTid); this.Document.SetValue("ccright", ccRight); this.Document.SetValue("thisurl", MyCommFun.getTotalUrl()); this.Document.SetValue("yuming", MyCommFun.getWebSite()); string openid = MyCommFun.RequestOpenid(); this.Document.SetValue("openid", openid); this.Document.Variables.SetValue("this", this); if (tType == TemplateType.Index) { //如果为首页页面 this.Document.SetValue("fxTitle", wxconfig.sitename); this.Document.SetValue("fxDesc", wxconfig.wbrief); this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(wxconfig.bgpic)); } if (tType == TemplateType.Class) { //如果为列表页面 ArticleClassPage(); } if (tType == TemplateType.News) { ArticleDetailPage(); } if (tType == TemplateType.Channel) { CategoryPage(); } //输出最终呈现的数据 this.Document.Render(HttpContext.Current.Response.Output); }
public void ArticleDetailPage() { DAL.article artDal = new DAL.article(); int aid = MyCommFun.RequestInt("aid"); Model.article article = artDal.GetModel(aid); if (article != null) { this.Document.SetValue("model", article); this.Document.SetValue("fxTitle", article.title); this.Document.SetValue("fxDesc", article.zhaiyao); this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(article.img_url)); } }
/// <summary> /// 频道,即二级分类 /// </summary> public void CategoryPage() { int parentId = MyCommFun.RequestInt("cid"); this.Document.SetValue("parentid", parentId);//父级id BLL.article_category cateBll = new BLL.article_category(); Model.article_category pCategory = cateBll.GetModel(parentId); if (pCategory == null) { return; } this.Document.SetValue("pcategory", pCategory);//父级分类基本信息 this.Document.SetValue("fxTitle", pCategory.title); this.Document.SetValue("fxDesc", pCategory.content); this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(pCategory.img_url)); //去二级分类 IList <Model.article_category> categorylist = tDal.GetCategoryListByWid(wid, -1, parentId, 2); if (categorylist != null && categorylist.Count > 0) { Model.article_category cat = new Model.article_category(); for (int i = 0; i < categorylist.Count; i++) { cat = categorylist[i]; if (cat.hasSun) { //有子分类 cat.link_url = MyCommFun.urlAddOpenid("/category.aspx?wid=" + wid + "&cid=" + cat.id, openid); } else { if (cat.link_url == null || cat.link_url.Trim() == "") { //如果link_url为空,则直接调用本系统的信息 cat.link_url = MyCommFun.urlAddOpenid("/list.aspx?wid=" + wid + "&cid=" + cat.id, openid); } else { cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid); } } } this.Document.SetValue("clist", categorylist);//二级分类列表 } }
/// <summary> /// 列表页面独有的数据 /// </summary> public void ArticleClassPage() { int category_id = MyCommFun.RequestInt("cid"); //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====-- Model.article_category category = tDal.GetCategoryByWid(wid, category_id); this.Document.SetValue("category", category); this.Document.SetValue("fxTitle", category.title); this.Document.SetValue("fxDesc", category.content); this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(category.img_url)); //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====-- Tag orderByTag = this.Document.GetChildTagById("norderby"); string orderby = orderByTag.Attributes["value"].Value.ToString(); Tag pagesizeTag = this.Document.GetChildTagById("npagesize"); string pagesizeStr = pagesizeTag.Attributes["value"].Value.ToString(); int currPage = 1; //当前页面 int recordCount = 0; //总记录数 int totPage = 1; //总页数 int pageSize = MyCommFun.Str2Int(pagesizeStr); //每页的记录数 if (pageSize <= 0) { pageSize = 10; } if (MyCommFun.RequestInt("page") > 0) { currPage = MyCommFun.RequestInt("page"); } DataSet artlist = new DataSet(); if (category_id != 0) { DAL.article artDal = new DAL.article(); artlist = artDal.GetList("news", category_id, pageSize, currPage, "wid=" + wid, orderby, out recordCount); if (artlist != null && artlist.Tables.Count > 0 && artlist.Tables[0].Rows.Count > 0) { DataRow dr; for (int i = 0; i < artlist.Tables[0].Rows.Count; i++) { dr = artlist.Tables[0].Rows[i]; if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0) { dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid); } else { dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&aid=" + dr["id"].ToString(), openid); } artlist.AcceptChanges(); } totPage = recordCount / pageSize; int yushu = recordCount % pageSize; if (yushu > 0) { totPage += 1; } if (totPage < 1) { totPage = 1; } } if (currPage > totPage) { currPage = totPage; } } else { currPage = 1; recordCount = 0; totPage = 1; } this.Document.SetValue("totPage", totPage); //总页数 this.Document.SetValue("currPage", currPage); //当前页 this.Document.SetValue("newslist", artlist); //文章列表 string beforePageStr = ""; //上一页 string nextPageStr = ""; //下一页 string bgrey = "c-p-grey"; string ngrey = "c-p-grey"; if (currPage <= 1) { beforePageStr = ""; bgrey = "disabled"; } else { beforePageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage - 1)); beforePageStr = "href=\"" + beforePageStr + "\""; bgrey = ""; } if (currPage >= totPage) { nextPageStr = ""; ngrey = "disabled"; } else { nextPageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage + 1)); nextPageStr = "href=\"" + nextPageStr + "\""; ngrey = ""; } this.Document.SetValue("bpage", beforePageStr); //上一页 this.Document.SetValue("npage", nextPageStr); //下一页 this.Document.SetValue("bgrey", bgrey); //上一页灰色的样式 this.Document.SetValue("ngrey", ngrey); //下一页灰色的样式 }