增加文章栏目伪静态规则1
This commit is contained in:
@@ -19,6 +19,7 @@ namespace COMCMS.Web.Controllers
|
||||
public IActionResult Index(int id = 0, int page = 1)
|
||||
{
|
||||
ArticleCategory model = ArticleCategory.FindById(id);
|
||||
|
||||
if (model == null)
|
||||
{
|
||||
return AlertAndGoBack("系统找不到本记录");
|
||||
@@ -88,16 +89,13 @@ namespace COMCMS.Web.Controllers
|
||||
}
|
||||
|
||||
ViewBag.cfg = cfg;
|
||||
string templatesname = "";//模板名称
|
||||
string templatesname = "Index.cshtml";//模板名称
|
||||
if (!string.IsNullOrEmpty(model.TemplateFile))
|
||||
{
|
||||
templatesname = model.TemplateFile.Replace(".cshtml", "").Replace(".aspx", "");
|
||||
return View(templatesname, model);
|
||||
}
|
||||
else
|
||||
{
|
||||
return View(model);
|
||||
templatesname = model.TemplateFile;
|
||||
//return Content(templatesname);
|
||||
}
|
||||
return View("~/Views/Article/" + templatesname, model); //固定死就是这个
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace COMCMS.Web.Controllers
|
||||
{
|
||||
ViewBag.cfg = cfg;
|
||||
ViewBag.about = Article.FindById(1);//关于我们
|
||||
return View();
|
||||
return View("~/Views/Home/Index.cshtml");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -47,19 +47,19 @@ namespace COMCMS.Web.Controllers
|
||||
}
|
||||
|
||||
#region 测试
|
||||
[Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
public IActionResult Test(string path = "")
|
||||
{
|
||||
string tel = "13332835377";
|
||||
return Content(tel.Substring(tel.Length - 5) + ";path:" + path);
|
||||
}
|
||||
[Route("{path1:regex([[a-zA-Z0-9-]])}/{path2:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
public IActionResult Test2(string path1 = "", string path2 = "")
|
||||
{
|
||||
ArticleController ac = new ArticleController();
|
||||
return ac.Index(1);
|
||||
//return Content(";ath1:" + path1+";path2:"+path2);
|
||||
}
|
||||
//[Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
//public IActionResult Test(string path = "")
|
||||
//{
|
||||
// string tel = "13332835377";
|
||||
// return Content(tel.Substring(tel.Length - 5) + ";path:" + path);
|
||||
//}
|
||||
//[Route("{path1:regex([[a-zA-Z0-9-]])}/{path2:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
//public IActionResult Test2(string path1 = "", string path2 = "")
|
||||
//{
|
||||
// ArticleController ac = new ArticleController();
|
||||
// return ac.Index(1);
|
||||
// //return Content(";ath1:" + path1+";path2:"+path2);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 测试拼音
|
||||
@@ -69,8 +69,34 @@ namespace COMCMS.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 系统文章、商品路由
|
||||
|
||||
#region 系统文章栏目、商品栏目路由
|
||||
/// <summary>
|
||||
/// 一级路径栏目
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
[Route("{path:regex([[a-zA-Z0-9-]])}/index.html")]
|
||||
[Route("{path:regex([[a-zA-Z0-9-]])}/index-{page:int}.html")]
|
||||
[Route("{path:regex([[a-zA-Z0-9-]])}/")]
|
||||
public IActionResult ShowCategory(string path,int page=1)
|
||||
{
|
||||
//先判断文章栏目
|
||||
ArticleCategory articleCategory = ArticleCategory.FindByFilePath("/" + path);
|
||||
if(articleCategory != null)
|
||||
{
|
||||
//return Content(articleCategory.Id.ToString());
|
||||
ArticleController ac = new ArticleController();
|
||||
return ac.Index(articleCategory.Id);
|
||||
}
|
||||
//再判断商品
|
||||
Category category = Category.FindByFilePath("/" + path);
|
||||
if(category != null)
|
||||
{
|
||||
ProductController pc = new ProductController();
|
||||
return pc.Index(category.Id,page);
|
||||
}
|
||||
return EchoTip("系统找不到本栏目!"+"/"+path);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user