增加完善分类伪静态

This commit is contained in:
2019-06-06 01:04:41 +08:00
parent 993de032b9
commit f9ee2df6fd
4 changed files with 80 additions and 7 deletions
+46
View File
@@ -6,6 +6,7 @@ using COMCMS.Core;
using COMCMS.Common;
using XCode;
namespace COMCMS.Web.Common
{
/// <summary>
@@ -14,6 +15,11 @@ namespace COMCMS.Web.Common
public class ViewsHelper
{
#region 获取分类链接
/// <summary>
/// 文章分类
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static string EchoURL(ArticleCategory model)
{
if (model == null)
@@ -23,6 +29,46 @@ namespace COMCMS.Web.Common
else
return $"/article/index/{model.Id}";
}
/// <summary>
/// 商品分类
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static string EchoURL(Category model)
{
if (model == null)
return "";
if (!string.IsNullOrEmpty(model.FilePath))
return model.FilePath + "/index.html";
else
return $"/product/index/{model.Id}";
}
/// <summary>
///
/// </summary>
/// <param name="ctype"></param>
/// <param name="id"></param>
/// <returns></returns>
public static string EchoURL(Utils.CMSType ctype,int id)
{
string url = "/";
switch (ctype)
{
case Utils.CMSType.ArticleCategory:
ArticleCategory ac = ArticleCategory.FindById(id);
url = EchoURL(ac);
break;
case Utils.CMSType.ProductCategory:
Category pc = Category.FindById(id);
url = EchoURL(pc);
break;
default:
url= "/";
break;
}
return url;
}
#endregion
}