protected override void InitPageTemplate(HttpContext context) { //获取所有栏目 Song.Entities.Columns[] cols = Business.Do <IColumns>().ColumnCount(this.Organ.Org_ID, colid, "news", true, -1); this.Document.SetValue("cols", cols); // this.Document.SetValue("colid", colid); //当前栏目 Song.Entities.Columns col = Business.Do <IColumns>().Single(colid); this.Document.SetValue("col", col); //资讯列表 Tag newsTag = this.Document.GetChildTagById("newslist"); if (newsTag != null) { //每页多少条记录 int newsSize = int.Parse(newsTag.Attributes.GetValue("size", "10")); //资讯栏目 int columns = int.Parse(newsTag.Attributes.GetValue("columns", "-1")); columns = columns <= 0 ? colid : columns; //简介的输出长度 int introlen = int.Parse(newsTag.Attributes.GetValue("introlen", "200")); int index = WeiSha.Common.Request.QueryString["index"].Int32 ?? 1; int sum = 0; Song.Entities.Article[] news = Business.Do <IContents>().ArticlePager(Organ.Org_ID, columns, true, "", newsSize, index, out sum); foreach (Song.Entities.Article art in news) { art.Art_Logo = Upload.Get["News"].Virtual + art.Art_Logo; if (string.IsNullOrWhiteSpace(art.Art_Intro)) { art.Art_Intro = ReplaceHtmlTag(art.Art_Details, introlen); } } this.Document.SetValue("newslist", news); //总页数 int pageSum = (int)Math.Ceiling((double)sum / (double)newsSize); int[] pageAmount = new int[pageSum]; for (int i = 0; i < pageAmount.Length; i++) { pageAmount[i] = i + 1; } this.Document.SetValue("pageAmount", pageAmount); this.Document.SetValue("pageIndex", index); } //通知公告 Tag noTag = this.Document.GetChildTagById("notice"); if (noTag != null) { int noCount = int.Parse(noTag.Attributes.GetValue("count", "10")); Song.Entities.Notice[] notice = Business.Do <INotice>().GetCount(Organ.Org_ID, true, noCount); this.Document.SetValue("notice", notice); } this.Document.RegisterGlobalFunction(this.getColumns); }
int colid = WeiSha.Common.Request.QueryString["colid"].Int32 ?? 0; //栏目id protected override void InitPageTemplate(HttpContext context) { //当前栏目 Song.Entities.Columns col = Business.Do <IColumns>().Single(colid); this.Document.Variables.SetValue("column", col); //获取所有栏目 Song.Entities.Columns[] cols = Business.Do <IColumns>().ColumnCount(this.Organ.Org_ID, colid, "news", true, -1); this.Document.SetValue("cols", cols); this.Document.RegisterGlobalFunction(this.isColumns); }
int colid = WeiSha.Common.Request.QueryString["colid"].Int32 ?? -1; //栏目id protected override void InitPageTemplate(HttpContext context) { if (Request.ServerVariables["REQUEST_METHOD"] == "GET") { Song.Entities.Columns col = Business.Do <IColumns>().Single(colid); this.Document.Variables.SetValue("column", col); } //此页面的ajax提交,全部采用了POST方式 if (Request.ServerVariables["REQUEST_METHOD"] == "POST") { int size = WeiSha.Common.Request.Form["size"].Int32 ?? 10; //每页多少条 int index = WeiSha.Common.Request.Form["index"].Int32 ?? 1; //第几页 int sumcount = 0; Song.Entities.Article[] arts = Business.Do <IContents>().ArticlePager(Organ.Org_ID, colid, true, "", size, index, out sumcount); string json = "{\"size\":" + size + ",\"index\":" + index + ",\"sumcount\":" + sumcount + ","; json += "\"items\":["; for (int i = 0; i < arts.Length; i++) { Song.Entities.Article art = arts[i]; //处理详情 art.Art_Details = ""; //art.Art_Details = Regex.Replace(art.Art_Details, @"\s{1,}", " ", RegexOptions.Singleline); //art.Art_Details = HttpUtility.UrlEncode(art.Art_Details); art.Art_Title = art.Art_Title.Replace("\"", """); art.Art_Title = HttpUtility.UrlEncode(art.Art_Title); // art.Art_Logo = Upload.Get["News"].Virtual + art.Art_Logo; if (string.IsNullOrWhiteSpace(art.Art_Intro)) { art.Art_Intro = ReplaceHtmlTag(art.Art_Details, 50); } json += art.ToJson() + ","; } if (json.EndsWith(",")) { json = json.Substring(0, json.Length - 1); } json += "]}"; Response.Write(json); Response.End(); } }