views:

41

answers:

1

Scenario:

platform: ASP.NET 4.0, MVC 2.0 (doesn't have to be MVC if it's not the right solution)

Create various widgets that inherit the same core markup:

<div class="widget">
    <div class="hd-widget">
        <!-- dynamically inject code here for each actual widget -->

    </div>
    <div class="bd-widget">
        <!-- dynamically inject code here for each actual widget -->
    </div>
    <div class="ft-widget">
        <!-- dynamically inject code here for each actual widget -->
    </div>
</div>

The above "simplified" example should be in some reusable control or masterpage.

The flow is something like this:

Controller -> View -> Partial View (1..n) -> widget markup

User instantiates an action which calls a controller. The controller tries to render a view that contains content + multiple widgets (left rail, right rail, etc). The Widgets all have their own individual partial views but each partial view should inherit or consume a base set of widget markup and have controller areas where to embed functionality.

Functionality in the head, body, and footer can either be plain text, HTML, or additional custom controls.

What is the best recommended approach?

A: 

I assume that your widgets will be stored in a DB.

I guess you'll need tables for Paths, PageSettings, Widgets, WidgetInstances, MasterPages, MasterPageZones and Zones.

I think that each widget will need to make a call in to RenderAction and this action will be stored in the DB against the widget. The widget header and footer can probably just be retrieved from the DB.

When I did this I spent quite a bit of time creating the dynamic editor for each of the widgets, the state of each widget is serialized in json, the only issue I'm still working on is dynamic validation of the widget editor.

Page Layouts are handled by a custom personalization class, storing the masterpage, path, userId etc.

It's quite an involved solution using JQuery sortable but really quick and SEO friendly.

Simon Hazelton