diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs index 0905789..af11af0 100644 --- a/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs +++ b/COMCMS.Web/Areas/AdminCP/Controllers/ArticleController.cs @@ -37,7 +37,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers //获取上级栏目 IList list = ArticleCategory.GetListTree(0, -1, true, false); ViewBag.ListTree = list; - //获取模板 + //获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情 + List listTpls = new List(); + var asms = AppDomain.CurrentDomain.GetAssemblies(); + foreach (var asmItem in asms) + { + var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList(); + if (types.Count == 0) continue; + foreach (var type in types) + { + string viewName = type.Name.Replace("Views_Article_", "") + ".cshtml"; + listTpls.Add(viewName); + } + } + ViewBag.ListTpl = listTpls; Core.Admin.WriteLogActions("查看添加文章栏目页面;"); return View(); } @@ -73,9 +86,21 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers //获取上级栏目 IList list = ArticleCategory.GetListTree(0, -1, true, false); ViewBag.ListTree = list; - //获取模板 - //List listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article"))); - //ViewBag.ListTpl = listtpl; + + //获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情 + List listTpls = new List(); + var asms = AppDomain.CurrentDomain.GetAssemblies(); + foreach (var asmItem in asms) + { + var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList(); + if (types.Count == 0) continue; + foreach (var type in types) + { + string viewName = type.Name.Replace("Views_Article_", "") + ".cshtml"; + listTpls.Add(viewName); + } + } + ViewBag.ListTpl = listTpls; Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;"); return View(entity); } diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml index 9abb2d7..98356d8 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/AddArticleCategory.cshtml @@ -76,28 +76,34 @@ - @*
- -
- -
-
-
- -
- + @foreach (var s in ViewBag.ListTpl) + { + if (s.ToLower().StartsWith("index")) { } - -
-
*@ + } + + + +
+ +
+ +
+
diff --git a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml index 8cfea3b..bc8c428 100644 --- a/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml +++ b/COMCMS.Web/Areas/AdminCP/Views/Article/EditArticleCategory.cshtml @@ -76,28 +76,34 @@
- @*
- -
- + @foreach (string s in ViewBag.ListTpl) + { + if (s.ToLower().StartsWith("index")) { - + } - -
+ } +
-
- -
- + @foreach (string s in ViewBag.ListTpl) + { + if (s.ToLower().StartsWith("detail")) { - + } - -
-
*@ + } + + +
diff --git a/COMCMS.Web/Controllers/ArticleController.cs b/COMCMS.Web/Controllers/ArticleController.cs index f94716f..b1684ea 100644 --- a/COMCMS.Web/Controllers/ArticleController.cs +++ b/COMCMS.Web/Controllers/ArticleController.cs @@ -90,10 +90,14 @@ namespace COMCMS.Web.Controllers ViewBag.cfg = cfg; string templatesname = "";//模板名称 if (!string.IsNullOrEmpty(model.TemplateFile)) + { templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", ""); - - return View(model); - + return View(templatesname, model); + } + else + { + return View(model); + } } #endregion @@ -137,9 +141,14 @@ namespace COMCMS.Web.Controllers } string templatesname = "";//模板名称 if (!string.IsNullOrEmpty(kind.TemplateFile)) + { templatesname = kind.DetailTemplateFile.Replace(".cshtml", "").Replace(".aspx", ""); - - return View(entity); + return View(templatesname, entity); + } + else + { + return View(entity); + } } #endregion }