/// <summary> /// 初始化当前页面模板数据 /// </summary> protected void InitPageTemplate() { #region 获取文档内容 //获取要生成的栏目ID archiveID = Utils.GetQueryInt("ID"); if (archiveID < 0) { Message.Dialog("生成错误,生成静态页的文档ID为空!", "-1", MessageIcon.Warning); } //获取栏目类型 channelType = Utils.GetQueryInt("type"); if (channelType < 0) { ArcListBLL arclistBll = new ArcListBLL(); Message.Dialog("生成错误,请选择要生成的文档类型!", "-1", MessageIcon.Warning); } //获取生成文档当前页数,默认为第一页 pageIndex = Utils.GetQueryInt("page"); if (pageIndex < 0) { pageIndex = 1; } ArcListBLL arcBll = new ArcListBLL(); List <Archive> archiveInfo = arcBll.GetArchiveInfo(archiveID, channelType); if (archiveInfo.Count > 0) { channelID = archiveInfo[0].ClassID; } else { return; } #endregion #region 获取当前位置 ArchiveField gobal = new ArchiveField(); //获取栏目当前位置 classUrl = this.__CLASSURL.Value; position = this.__POSITION.Value; relation = this.__RELATION.Value; if (classUrl.Length == 0 || relation.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); Arc_Class classInfo = classBll.GetModel(channelID); classUrl = this.__CLASSURL.Value = classInfo.ClassPath; relation = this.__RELATION.Value = classInfo.Relation.TrimEnd('.').Replace('.', ','); } if (position.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); DataTable dt = classBll.GetThisPlace(relation); position += "<a href=\"/\">首页</a> » "; for (int i = 0; i < dt.Rows.Count; i++) { position += "<a href=\"" + dt.Rows[i]["ClassEName"] + "\">" + dt.Rows[i]["ClassName"] + "</a>"; if (i + 1 < dt.Rows.Count) { position += " » "; } } this.__POSITION.Value = gobal.Position = position; } #endregion #region 获取上一篇、下一篇链接 int count = archiveInfo.Count; for (int i = 1; i < count; i++) { if (archiveInfo[i] != null) { string temp = "<a href=\"" + archiveInfo[i].Url + "\">" + archiveInfo[i].Title + "</a>"; if (archiveInfo[i].ID < archiveID) { gobal.Prior = temp; } else { gobal.Next = temp; } } } #endregion #region 获取配置信息 SiteConfigInfo site = ConfigAccess.LoadConfig <SiteConfigInfo>("CFG_SITE"); #endregion this.Document.Variables.SetValue("field", archiveInfo[0]); this.Document.Variables.SetValue("gobal", gobal); this.Document.Variables.SetValue("site", site); }
/// <summary> /// 初始化当前页面模板数据 /// </summary> protected void InitPageTemplate() { //获取要生成的栏目ID channelID = Utils.GetQueryInt("ID"); if (channelID < 0) { Message.Dialog("生成错误,生成静态页的栏目ID为空!", "-1", MessageIcon.Warning); } //获取栏目类型 channelType = Utils.GetQueryString("type"); if (channelType.Length == 0) { ArcListBLL arclistBll = new ArcListBLL(); channelType = arclistBll.GetChannelType(channelID); } //获取记录总数 totalRecord = Utils.GetQueryInt("total"); if (totalRecord < 0) { ArcListBLL arclistBll = new ArcListBLL(); totalRecord = arclistBll.GetArcCount(channelID, channelType); } //获取生成栏目当前页数 pageIndex = Utils.GetQueryInt("page"); if (pageIndex < 0) { Message.Dialog("生成错误,生成静态页的当前页数为空!", "-1", MessageIcon.Warning); } //获取分页大小 pageSize = Utils.GetQueryInt("size"); //获取分页选项 pageItem = this.__PAGEITEM.Value; if (pageSize < 0 || pageItem.Length == 0) { //分页大小和分页选项从PageList标签中获取 ElementCollection <Tag> tags = this.Document.GetChildTagsByTagName("PageList"); foreach (Tag tag in tags) { pageSize = TypeConvert.ToInt32(tag.Attributes["PageSize"].Value); pageItem = tag.Attributes["Item"].Value.ToString(); } this.__PAGEITEM.Value = pageItem; } //获取栏目当前位置 classUrl = this.__CLASSURL.Value; listTemplet = this.__LISTTEMPLET.Value; indexRule = this.__INDEXRULE.Value; position = this.__POSITION.Value; relation = this.__RELATION.Value; if (classUrl.Length == 0 || listTemplet.Length == 0 || indexRule.Length == 0 || relation.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); Arc_Class classInfo = classBll.GetModel(channelID); classUrl = this.__CLASSURL.Value = classInfo.ClassPath; listTemplet = this.__LISTTEMPLET.Value = classInfo.ListTemplet; indexRule = this.__INDEXRULE.Value = classInfo.IndexRule; relation = this.__RELATION.Value = classInfo.Relation.TrimEnd('.').Replace('.', ','); } if (position.Length == 0) { Arc_ClassBLL classBll = new Arc_ClassBLL(); DataTable dt = classBll.GetThisPlace(relation); position += "<a href=\"/\">首页</a> » "; for (int i = 0; i < dt.Rows.Count; i++) { position += "<a href=\"" + dt.Rows[i]["ClassEName"] + "\">" + dt.Rows[i]["ClassName"] + "</a>"; if (i + 1 < dt.Rows.Count) { position += " » "; } } this.__POSITION.Value = position; } //设置自定义属性 PageListField field = new PageListField(); field.CurrentPage = pageIndex; field.TotalPage = PageSeting.GetPageCount(totalRecord, pageSize); field.TotalRecord = totalRecord; field.PageIndex = PageSeting.GetPageNum(pageIndex, field.TotalPage, 10, "createlist.aspx?id=10&page={0}", pageItem); field.Position = position; //gobal.PageIndex = gobal.PageIndex.Replace(string.Format("list/{0}/1/", channelID), "index.html"); this.Document.Variables.SetValue("field", field); }