This project is read-only.

Integrating Orchard into existing MVC site

Topics: Core, Customizing Orchard
Mar 5, 2012 at 9:45 PM

I would like to hear how in general others solve this problem, because I think it is a very typical scenario.

A site is 90% e-commerce with 10% (or even less) of dynamically managed content). As far as content management goes, there is no even a requirement to create new pages. What needed is simply editing content on home page and few other pages like about, shipping, etc. It is fine to statically link CMS-driven pages. Content pages should have images.

Orchard is a great platform.  It is nice that it can be extended with custom modules. However, if going with Orchard the resutling solution will be the 90% CMS + 10% e-commerce site, which is opposite from what I need. I don't CMS to take over the whole site, it needs to live in its corner.

I was told that Orchard wasn't design for such a scenario. Okay, but how in general such problem can be solved? One scenario I can think of is to have two sites, one e-commerce and one Orchard CMS and try blending them in. It doesn't seem to be an elegant solution, though...




Mar 5, 2012 at 10:23 PM
Edited Mar 5, 2012 at 10:25 PM

It's true that Orchard has a lot of content management capabilities out of the box, but more then anything, Orchard is more of an Extension Host/Shell, meaning that it enables you to write full blown MVC areas. The entire site can be driven using that single (or perhaps multiple) area. The advantage being, of course, that you can take advantage of Orchard features anytime you want. You can disable all but the core the modules. All of the e-commerce features are powered by your area: products, customers, shoppingcart, payment, etc. You don't even need to use the Orchard database to create your ecommerce tables.

If you still dislike having a fullblown area hosted within Orchard, then you could perhaps create the e-commerce services as a web API, which Orchard consumes (using your own built module / area consuming the services and exposing it to Orchard in the form of shapes and widgets and pages).

In any case, it would be horrific blending two different sites together (if by that you mean IFraming :)).


Mar 5, 2012 at 11:04 PM

I would argue that e-commerce is largely content.

Mar 5, 2012 at 11:29 PM

Good point. At the very least, products are content, which would make up the most part of any commerce site. Also, a personalized user area is typically built-in into the site - Orchard has it. As for shipping and invoicing, that could be handled via another application if so required, although that might very well be seen as (secured) content, viewable by the customer.

Mar 6, 2012 at 1:11 PM

Ok, let's walk through an oversimplified example. Suppose that there is an e-commerse site (product catalog, shopping cart, ordering). Assume that there is About static page (regular MVC view page). I want to be able to edit this page (add and edit text). I would need to build a regular Orchard site and move existing functionality into an area, correct? I am no sure how can it even work. For example, the site has its own navigation. Do I need to somehow surface it in Orchard? What about the site layout, graphics, styles?

Mar 6, 2012 at 3:27 PM
Edited Mar 6, 2012 at 3:28 PM

Correct. It's easy to surface the navigation into Orchard: just create a class in your module that implements INavigationProvider. Inside that class you build up the navigation structure, which you then render from within your views. To see how that works, take Piotr's excellent Advanced Menu module as an example (or even just use that one, enabling easy navigation management from the backend UI).

With regards to layout, graphics and styles, you can do this entirely from within your MVC area: The ViewResults that your controllers return will be rendered just like any other MVC application would. Just as an MVC Area, your module will contain the images, views, styles and scripts that your application requires.

From within your module, you could easily use the IContentManager service to query the "static" About page, render it into a so called "shape" (also using the IContentManager), which is then skinned by a Razor view (shapes are simply dynamic objects which act as the view model for a view, which is called the shape template).

When you do it this way, you get what you want: your Module will be on the foreground, while Orchard serves you as you so see fit.

Mar 6, 2012 at 3:30 PM

However, I should also add that Orchard has great Theming support, so you might want to take advantage of that and separate your existing app into a theme and a Module, which I would recommend as it enables you to leverage existing Orchard features. But it's perfectly fine to do it all by yourself, and just leverage some of Orchard's features.

Mar 7, 2012 at 1:12 PM

It sounds that I should have started with Orchard rather than trying to retrofit my project to enable content management.

Mar 7, 2012 at 1:15 PM
bertrandleroy wrote:

I would argue that e-commerce is largely content.

In some sence everything is content. What I have in mind is user or admin-defined content. That is edit page, add announcement and so on.