3
votes

I'm trying to migrate an existing ASP.NET MVC 3 website into Orchard, so I can continue to build the site while taking advantage of the extended features offered by Orchard. I'm attempting to wrap the entire existing site into an Orchard Module, so I can keep all the existing functionality intact, and continue adding features, or porting old features into the new paradigm as needed.

The main issue I'm having with a straight copy into Orchard is that I've taken advantage of the Layout hierarchy in MVC 3 to specify the same parent layout for related pages, which in turn may have its own parent layout, and so on.

When I copied in my existing views, I get the error that Layout is a read-only property on the custom Orchard WebPageView, but when I change the base view type back to the standard MVC 3 base type, the paths do not match up to my views because of the Module folder structure.

Is the ability to specify nested layouts simply not supported for sites running in Orchard, or is there a built-in work-around that I'm missing?

Thanks! -J

1

1 Answers

2
votes

Orchard's layout system predates MVC's and works a little differently. I'm afraid you will have to refactor things a bit. The views in Orchard rely on the idea of a shape, which is a dynamic object analogous to a view model. When the time comes to render a shape, the system looks for the most appropriate template to transform it into html. Most controller actions return a shape result that will be rendered as a child of the content zone that must be defined in the layout shape. The layout shape rendering can be changed by specifying alternates for it (see http://weblogs.asp.net/bleroy/archive/2010/12/14/switching-the-layout-in-orchard-cms.aspx).

So in the end Orchard doesn't use the sort of inverted master-page-like layout system that Razor/ASP.NET Web Pages/MVC3 promotes. Instead you use shapes and their alternates to get similar results, but the viewpoint is different as shapes get added into nested containers rather than have contained objects specify what they get inserted into.