增加文章模板选择
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -76,28 +76,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@*<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
<option value="@s" >@s</option>
|
||||
}
|
||||
</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)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
{
|
||||
if (s.ToLower().StartsWith("index"))
|
||||
{
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>*@
|
||||
}
|
||||
</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)
|
||||
{
|
||||
if (s.ToLower().StartsWith("detail"))
|
||||
{
|
||||
<option value="@s">@s</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||
<div class="col-sm-8">
|
||||
|
||||
@@ -76,28 +76,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@*<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" name="TemplateFile" id="TemplateFile">
|
||||
@foreach (var s in ViewBag.ListTpl)
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">栏目模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<select class="form-control" asp-for="TemplateFile">
|
||||
@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 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)
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">文章模板:</label>
|
||||
<div class="col-sm-8">
|
||||
<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>
|
||||
</div>*@
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">隐藏栏目:</label>
|
||||
<div class="col-sm-8">
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user