增加文章模板选择

This commit is contained in:
2018-11-30 18:40:41 +08:00
parent fb0a5b80eb
commit 2cb8f6dfee
4 changed files with 91 additions and 45 deletions
@@ -37,7 +37,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
//获取上级栏目
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListTree = list;
//获取模板
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
List<string> listTpls = new List<string>();
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<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
ViewBag.ListTree = list;
//获取模板
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
//ViewBag.ListTpl = listtpl;
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
List<string> listTpls = new List<string>();
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);
}