增加文章模板选择
This commit is contained in:
@@ -37,7 +37,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
||||||
ViewBag.ListTree = list;
|
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("查看添加文章栏目页面;");
|
Core.Admin.WriteLogActions("查看添加文章栏目页面;");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
@@ -73,9 +86,21 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
||||||
ViewBag.ListTree = list;
|
ViewBag.ListTree = list;
|
||||||
//获取模板
|
|
||||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||||
//ViewBag.ListTpl = listtpl;
|
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 + ")页面;");
|
Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,28 +76,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@*<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||||
@foreach (var s in ViewBag.ListTpl)
|
@foreach (var s in ViewBag.ListTpl)
|
||||||
{
|
{
|
||||||
<option value="@s" >@s</option>
|
if (s.ToLower().StartsWith("index"))
|
||||||
}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-3 control-label">文章模板:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<select class="form-control" name="DetailTemplateFile" id="DetailTemplateFile">
|
|
||||||
@foreach (var s in ViewBag.ListTpl)
|
|
||||||
{
|
{
|
||||||
<option value="@s">@s</option>
|
<option value="@s">@s</option>
|
||||||
}
|
}
|
||||||
</select>
|
}
|
||||||
</div>
|
</select>
|
||||||
</div>*@
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">文章模板:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control" name="DetailTemplateFile" id="DetailTemplateFile">
|
||||||
|
@foreach (var s in ViewBag.ListTpl)
|
||||||
|
{
|
||||||
|
if (s.ToLower().StartsWith("detail"))
|
||||||
|
{
|
||||||
|
<option value="@s">@s</option>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|||||||
@@ -76,28 +76,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@*<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
<select class="form-control" asp-for="TemplateFile">
|
||||||
@foreach (var s in ViewBag.ListTpl)
|
@foreach (string s in ViewBag.ListTpl)
|
||||||
|
{
|
||||||
|
if (s.ToLower().StartsWith("index"))
|
||||||
{
|
{
|
||||||
<option value="@s" @(Model.TemplateFile == s?"selected":"")>@s</option>
|
<option value="@s">@s</option>
|
||||||
}
|
}
|
||||||
</select>
|
}
|
||||||
</div>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label class="col-sm-3 control-label">文章模板:</label>
|
<div class="form-group">
|
||||||
<div class="col-sm-8">
|
<label class="col-sm-3 control-label">文章模板:</label>
|
||||||
<select class="form-control" name="DetailTemplateFile" id="DetailTemplateFile">
|
<div class="col-sm-8">
|
||||||
@foreach (var s in ViewBag.ListTpl)
|
<select class="form-control" asp-for="DetailTemplateFile">
|
||||||
|
@foreach (string s in ViewBag.ListTpl)
|
||||||
|
{
|
||||||
|
if (s.ToLower().StartsWith("detail"))
|
||||||
{
|
{
|
||||||
<option value="@s" @(Model.DetailTemplateFile == s?"selected":"")>@s</option>
|
<option value="@s">@s</option>
|
||||||
}
|
}
|
||||||
</select>
|
}
|
||||||
</div>
|
</select>
|
||||||
</div>*@
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|||||||
@@ -90,10 +90,14 @@ namespace COMCMS.Web.Controllers
|
|||||||
ViewBag.cfg = cfg;
|
ViewBag.cfg = cfg;
|
||||||
string templatesname = "";//模板名称
|
string templatesname = "";//模板名称
|
||||||
if (!string.IsNullOrEmpty(model.TemplateFile))
|
if (!string.IsNullOrEmpty(model.TemplateFile))
|
||||||
|
{
|
||||||
templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
|
templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
|
||||||
|
return View(templatesname, model);
|
||||||
return View(model);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -137,9 +141,14 @@ namespace COMCMS.Web.Controllers
|
|||||||
}
|
}
|
||||||
string templatesname = "";//模板名称
|
string templatesname = "";//模板名称
|
||||||
if (!string.IsNullOrEmpty(kind.TemplateFile))
|
if (!string.IsNullOrEmpty(kind.TemplateFile))
|
||||||
|
{
|
||||||
templatesname = kind.DetailTemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
|
templatesname = kind.DetailTemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
|
||||||
|
return View(templatesname, entity);
|
||||||
return View(entity);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return View(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user