与ASP.NET MVC写了一个博客引擎主题选择思路 [英] Theme Selector idea for a Blog Engine written with ASP.NET MVC
问题描述
我已经开始建立一个博客引擎,它是完全unprofesional,这意味着它们没有被任何人。所以,用简单的英语,我不能告诉你继续运行自己这一点,你会很快乐。
I have started to build a blog engine which is totally unprofesional and meant to be not used by anyone. So, in plain English I cannot tell that you go ahead and run this for yourself and you will be happy.
您可能会看到完整的code到目前为止,我已经写了:
You may see the complete code I have written so far :
https://github.com/tugberkugurlu/MvcBloggy
虽然现在我工作的 DAL 后,我也试着放下什么,我需要做的。有一点我坚持在这里是如何处理主题选择的博客引擎。
While now I am working on DAL, I also try to lay down what I need to do. One point I am stuck here is how I can handle theme selection for the blog engine.
- 我应该如何开始建立的基础?我应该创建一个框架HTML并让其他人写CSS和基本选择?还是其他什么东西?
- 在ASP.NET MVC结构来看,这将是处理这一功能的最好的方法。
我不知道任何你们已经做过这样的事情至今。我想AP preciate如果你可以提供一种方式。
I am not sure any of you guys has ever done something like this so far. I would appreciate if you can provide a way.
推荐答案
我建议你看一下 NBlog temable博客引擎
I suggest you to look at NBlog temable blog engine
https://github.com/ChrisFulstow/NBlog
在特定的,看一下类的 ThemeableRazorViewEngine.cs
In particular, look at the class ThemeableRazorViewEngine.cs
<一个href=\"https://github.com/ChrisFulstow/NBlog/blob/master/NBlog.Web/Application/Infrastructure/ThemeableRazorViewEngine.cs\" rel=\"nofollow\">https://github.com/ChrisFulstow/NBlog/blob/master/NBlog.Web/Application/Infrastructure/ThemeableRazorViewEngine.cs
using System.Web.Mvc;
using NBlog.Web.Application.Service;
namespace NBlog.Web.Application.Infrastructure
{
public class ThemeableRazorViewEngine : RazorViewEngine
{
private readonly IThemeService _themeService;
public ThemeableRazorViewEngine(IThemeService themeService)
{
_themeService = themeService;
base.ViewLocationFormats = new[]
{
_themeService.Current.BasePath + "/Views/{1}/{0}.cshtml",
_themeService.Current.BasePath + "/Views/Shared/{0}.cshtml",
"~/Themes/Default/Views/{1}/{0}.cshtml"
};
base.PartialViewLocationFormats = new string[] {
_themeService.Current.BasePath + "/Views/{1}/{0}.cshtml",
_themeService.Current.BasePath + "/Views/Shared/{0}.cshtml",
"~/Themes/Default/Views/Shared/{0}.cshtml"
};
}
public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
{
// bypass the view cache, the view will change depending on the current theme
const bool useViewCache = false;
return base.FindView(controllerContext, viewName, masterName, useViewCache);
}
}
}
这篇关于与ASP.NET MVC写了一个博客引擎主题选择思路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!