ContentPart is displayed in one ContentType but not in other

Topics: Customizing Orchard, Writing modules
Aug 29, 2011 at 3:26 PM
Edited Aug 29, 2011 at 5:01 PM

I have implemented a custom ContentPart "MarinaPart", which also defines a new ContentType "Marina":

 

public int UpdateFrom5()
		{
		ContentDefinitionManager.AlterTypeDefinition("Marina",
							 cfg => cfg
								.WithPart("CommonPart")
								.WithPart("RoutePart")
								.WithPart("MarinaPart")
								.WithPart("Map")
								.WithPart("TagsPart")
								.WithPart("LocalizationPart")
								.WithPart("PublishLater")
								.Creatable()
								.Indexed());
			return 6;
		}

 

The ContentPart "Map" is the one I developed according to the tutorial: http://www.orchardproject.net/docs/Writing-a-content-part.ashx

Everything is working fine except that the Shapes of the "Map" are not showing. I open up an existing ContentItem of the ContentType "Marina", and it does not show the Edit-View of "Map". Though while debugging it does enter the Driver for the Editor.

I have added the ContentPart "Map" to the ContentType "Page" (via the Dashboard), and there everything works fine. But strangely while debugging the Editor-Driver is not entered, but the Shape is displayed.

Can someone explain to me, what I may have done wrong? (I hope that there it makes not much of a difference that I added the "Map"-ContentPart one time via Code and one time via Dashboard.)

Coordinator
Aug 29, 2011 at 7:27 PM

Missing placement maybe?

Aug 31, 2011 at 3:39 PM

We solved the problem. Here our findings:

The placement files were fine.

The "Map" Module had a migrations.cs-file with this line:

ContentDefinitionManager.AlterPartDefinition(typeof(MapPart).Name, builder => builder.Attachable());

typeof(MapPart).Name results in "MapPart", not "Map", even though the ContentPart is displayed as "Map" in the dashboard. In the code you have to use the string "MapPart".

So the only thing we needed to change was 

		public int UpdateFrom6()
		{
			ContentDefinitionManager.AlterTypeDefinition("Marina",
			                                             builder => builder
			                                                        	.RemovePart("Map")
			                                                        	.WithPart("MapPart"));
			return 7;
		}