public override string GetCategory(Category category, int pageIndex, params object[] args) { string tplID = null; ModuleBLL mbll = new ModuleBLL(); Module m = mbll.GetModule(category.ModuleID); if (m != null) { TemplateBind tb = tbbll.GetCategoryTemplateBind(category.ID); if (tb != null) { string id = this.GetTemplateID(tb.TplPath); if (id != null) { tplID = "/" + id; } } } //设置默认的模板 if (String.IsNullOrEmpty(tplID)) { tplID = this.FormatTemplatePath("category"); } Category parentCategory = cbll.GetParent(category.Lft, category.Rgt); //用于当前的模板共享数据 Cms.Context.Items["category.tag"] = category.Tag; Cms.Context.Items["module.id"] = category.ModuleID; Cms.Context.Items["page.index"] = pageIndex; //解析模板 return MultLangPageUtility.Require(tplID, new { categoryName = category.Name, categoryTag = category.Tag, parentCategoryName = parentCategory == null ? "" : parentCategory.Name, parentCategoryTag = parentCategory == null ? "" : parentCategory.Tag, pageIndex = pageIndex, moduleId = category.ModuleID, pageTitle = pageIndex == 1 ? "" : "(第" + pageIndex + "页)", keywords = category.Keywords, description = category.Description }); }
public override string GetArchive(Category category, Archive archive, params object[] args) { // return base.GetArchive(category, archive, args); #region 属性 /* //验证密码 PropertyBLL pbll = new PropertyBLL(); var a = pbll.GetProperty(category.ModuleID, "pwd"); if (a != null) { var json = archive.GetPropertiesJson(); string key = json.GetValue("pwd"); if (!String.IsNullOrEmpty(key)) { string requireKey = HttpContext.Current.Request.QueryString["pwd"]; if (requireKey != key) { HttpContext.Current.Response.Write("<div style='margin:0 auto;padding:30px 0'>请输入密码:<input type='text'/><input type='button' value='提交' onclick=\"location.replace(location.href+'?pwd='+this.previousSibling.value)\"/></div>"); HttpContext.Current.Response.End(); } } }*/ #endregion //获取模板ID string tplID =null; ModuleBLL mbll = new ModuleBLL(); Module m = mbll.GetModule(category.ModuleID); if (m != null) { TemplateBind tb = tbbll.GetArchiveTemplateBind(archive.ID, category.ID); if (tb != null) { string id = this.GetTemplateID(tb.TplPath); if (id != null) { tplID = "/" + id; } } } //设置默认的模板 if (String.IsNullOrEmpty(tplID)) { tplID = this.FormatTemplatePath("archive"); } string description=ArchiveUtility.GetOutline(archive,200); //用于当前的模板共享数据 Cms.Context.Items["archive.id"] = archive.ID; Cms.Context.Items["category.tag"] = category.Tag; Cms.Context.Items["module.id"] = category.ModuleID; //解析模板 string html= MultLangPageUtility.Require(tplID, new { id2=string.IsNullOrEmpty(archive.Alias)?archive.ID:archive.Alias, id=archive.ID, title = archive.Title, categoryName = category.Name, categoryTag = category.Tag, moduleId = category.ModuleID, author = archive.Author, content = archive.Content, tags=archive.Tags, keywords = archive.Tags, description=description.Replace("\"",String.Empty), outline=description, count = archive.ViewCount, source = String.IsNullOrEmpty(archive.Source) ? "原创" : archive.Source, publishdate = string.Format("{0:yyyy-MM-dd}", archive.CreateDate) }); HttpRequest request=HttpContext.Current.Request; //如果包含查询,则加入标签 if (!String.IsNullOrEmpty(request.Url.Query)) { //将查询参数作为标签 html = global::Ops.Template.TemplateRegexUtility.Replace(html, a => { if (request[a.Groups[1].Value] != null) { return request[a.Groups[1].Value]; } return a.Value; }); } // //TODO:模板被替换成空白 // return html; }