18

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

-- Christian

Christian Sparre
  • 955
  • 3
  • 15
  • 25

1 Answers1

16

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",
wal
  • 17,409
  • 8
  • 74
  • 109
  • Thanks wal, exactly what I was looking for :) getting more and more amazed by the possibilities of MVC! – Christian Sparre Aug 10 '11 at 12:12
  • glad i could help. the source code is full of goodies, take a look at the lib and packages folders to see all the third party libraries used. – wal Aug 10 '11 at 12:28