Map content part not converted correctly to widget

Topics: Troubleshooting
May 20, 2011 at 6:06 PM

I followed the Orchard documentation article, Writing a content part, followed by Writing a widget, which is supposed to convert the same Map content part created in the former to a widget. The content part in my app behaves as expected, but the widget does not. I am able to include "Map" as a part in my content types. Is the migration the only requirement to "convert" the part to a widget?

public int UpdateFrom1()
{
    // Create a new widget content type with our map
    ContentDefinitionManager.AlterTypeDefinition("MapWidget", cfg => cfg
        .WithPart("MapPart")
        .WithPart("WidgetPart")
        .WithPart("CommonPart")
        .WithSetting("Stereotype", "Widget"));

    return 2;
}

I'm still new to Orchard, so I'm not even sure what other widgets/modules I can review to see what else they might be doing? UpdateFrom1 did, in fact, successfully update the Geolocation module. But, when I attempt to add a Map Widget to a zone in any theme, it's not even an option. I even went back and copy+pasted the code snippets to make sure I didn't typo something the first time around. What else am I missing?

Thanks in advance!

 

Coordinator
May 20, 2011 at 6:11 PM

That should be it. Are you sure that the migration actually ran?

May 20, 2011 at 6:24 PM

I'm pretty sure it did. After the next run, my modules page indicated I needed an update to Map, so I clicked update and and it was successful.

Continuing to follow up, I just tried another update (hopefully that didn't compound this problem) like so:

public int UpdateFrom2()
{
    // Create a new widget content type with our map
    ContentDefinitionManager.AlterTypeDefinition("MapWidget", cfg => cfg
        .WithPart("MapPart")
        .WithPart("WidgetPart")
        .WithPart("CommonPart")
        .WithSetting("Stereotype", "Widget"));

    // note the secondary update here that does exactly the same
    return 3;
}

And it worked! I know I clicked update (and it was successful) once before after completing the Writing a widget conversion, so what did it update that time if not the UpdateFrom1 migration?

Coordinator
May 20, 2011 at 6:28 PM

Hard to say. Maybe you changed it at some point after running it a first time?

May 20, 2011 at 6:31 PM

Will this second migration have any impact on deployment or future updates? Or do they all run in series one time only dependent on the previous version? Thanks for your help!

Coordinator
May 20, 2011 at 6:37 PM

They only run once.