I'm looking for input on how to do "themes" in MVC 3 in the best way. I guess a custom view engine is needed to take care of locating the view files etc.
我正在寻找有关如何以最佳方式在MVC 3中执行“主题”的输入。我想需要一个自定义视图引擎来处理查看视图文件等。
I also would like the theme system to be extensible, so that if it's only one of the views I would like to change the others still use the default. Kind of like the Orchard project does?
我也希望主题系统是可扩展的,所以如果它只是其中一个视图我想改变其他视图仍然使用默认值。有点像Orchard项目吗?
A imagine a folder structure like ~/Themes/Default/Views etc.
想象一下像〜/ Themes / Default / Views等文件夹结构。
I have found a few MVC 1.0 and 2.0 examples, but nothing that fits my needs exactly. I need something that takes advantage of all the ASP.NET MVC 3.0 features and goodies of the Razor view engine :)
我找到了一些MVC 1.0和2.0示例,但没有任何内容完全符合我的需求。我需要一些利用所有ASP.NET MVC 3.0功能和Razor视图引擎的好东西的东西:)
Any input and ideas will really be appreciated
任何意见和想法将真的很感激
-- Christian
- 基督徒
1 个解决方案
#1
15
Check out the FunnelWeb blog engine.
查看FunnelWeb博客引擎。
Its open source, the code is very readable, it uses MVC3 and it has support for themes
它的开源,代码非常易读,它使用MVC3并且它支持主题
FunnelWeb is written in ASP.NET MVC 3, using the Razor view engine. The source code is simple and easy to jump in to.
FunnelWeb是使用Razor视图引擎在ASP.NET MVC 3中编写的。源代码简单易用。
The best thing to do is to download the source (release or dev) and check how themes are implemented.
最好的办法是下载源代码(发布版或开发代码)并检查主题的实现方式。
And yes, a custom view engine is used. Check out FunnelWebViewEngine
which has code like this:
是的,使用自定义视图引擎。查看FunnelWebViewEngine,其代码如下:
lastEngine = new RazorViewEngine();
lastEngine.ViewLocationFormats =
new[]
{
"~/Themes/" + settings.Theme + "/Views/{1}/{0}.cshtml",
#1
15
Check out the FunnelWeb blog engine.
查看FunnelWeb博客引擎。
Its open source, the code is very readable, it uses MVC3 and it has support for themes
它的开源,代码非常易读,它使用MVC3并且它支持主题
FunnelWeb is written in ASP.NET MVC 3, using the Razor view engine. The source code is simple and easy to jump in to.
FunnelWeb是使用Razor视图引擎在ASP.NET MVC 3中编写的。源代码简单易用。
The best thing to do is to download the source (release or dev) and check how themes are implemented.
最好的办法是下载源代码(发布版或开发代码)并检查主题的实现方式。
And yes, a custom view engine is used. Check out FunnelWebViewEngine
which has code like this:
是的,使用自定义视图引擎。查看FunnelWebViewEngine,其代码如下:
lastEngine = new RazorViewEngine();
lastEngine.ViewLocationFormats =
new[]
{
"~/Themes/" + settings.Theme + "/Views/{1}/{0}.cshtml",