Composing Widgets within Widgets

Topics: Customizing Orchard
May 6, 2013 at 8:50 PM
One of the feature I like about Orchard CMS is the ability to assign multiple parts to a content, promoting re-usability. Now assume I have 3 widgets, which are:-
  • Country_Widget (Country : <<ddlCountry>>)
  • Region_Widget (Region : <<ddlRegion) --> Zip Code, Postal Code, OThers
  • Address_Widget
    Address Line 1 : <<txtBox>> --> Street Address, P.O Box, Company Name, etc..)
    Address Line 2: <<txtBox>> --> Apartment, Suite, etc..
    City: <<txtBox>>
Now, here's where I want to re-Use the Address_Widget, such that at the time of render, it will output:
Address Line 1 : <<txtBox>>
Address Line 2 : <<txtBox>>
Country_Widget -->> Hoping to reuse the widget here
City : <<txtBox>>
Region_Widget -->> Similary, to reuse the Region Widget.

Any reference implementation would be helpful / url, such that I can trace the source-code.

Is this possible ?
May 6, 2013 at 10:57 PM
Those three things should certainly not be widgets, but maybe parts. I'm saying maybe because they seem to be very much related: they all have to do with geolocation. So I really don't see why you'd want them on different entities.
May 8, 2013 at 3:55 PM
Let's just then assume I have an Address Part. For the purpose of argument, I have another PersonPart (Eg: First Name, Last Name, etc..).
Is this then possible to place the AddressPart within the PersonPart ?
May 8, 2013 at 5:25 PM
Edited May 8, 2013 at 5:26 PM
When the AddressPart Content Part and the PersonPart Content Part is added to a ... let's say Person Content Type both Content Parts would appear in the same shape. Then if you wanted to move stuff around I've used stuff like this before in an alternate for the Person (i.e. Content-Person.cshtml):
WorkContext.Layout.AsideSecond.Add(new MvcHtmlString(Model.ContentItem.SuccessStories.ContactInformation.Value), "1");
Or you can use the file to move stuff to a new zone:
<Match ContentType="Person">
<Match DisplayType="Detail">
    <Place Fields_MediaPicker-Image="/AsideSecond:1"
I'm sure there's other ways to do this as well. Hope that helps.