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.
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?
A imagine a folder structure like ~/Themes/Default/Views etc.
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 :)
Any input and ideas will really be appreciated
-- Chr开发者_开发问答istian
Check out the FunnelWeb blog engine.
Its open source, the code is very readable, it uses MVC3 and it has support for themes
FunnelWeb is written in ASP.NET MVC 3, using the Razor view engine. The source code is simple and easy to jump in to.
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:
lastEngine = new RazorViewEngine();
lastEngine.ViewLocationFormats =
new[]
{
"~/Themes/" + settings.Theme + "/Views/{1}/{0}.cshtml",
精彩评论