I am attempting to add a taxonomy to a custom type in orchard cms.
ContentDefinitionManager.AlterPartDefinition("ExpertPart",
b => b
.WithField("ExpertOf", fld => fld
.OfType("TaxononmyField")
.WithDisplayName("Expert Of")
.WithSetting("TaxonomyFieldSettings.Taxonomy", "ExpertOf")
.WithSetting("TaxonomyFieldSettings.LeavesOnly", "false")
.WithSetting("TaxonomyFieldSettings.SingleChoice", "true")
.WithSetting("TaxonomyFieldSettings.Required", "true")));
When i run this code the taxonomy shows up under "parts" and not "fields" in the content definition. I can manually add this to fields and it works fine. What is the new migration code for Orchard 1.10 that allows you to add a taxonomy field programatically to a custom content type?
Thanks for your help with this! So I have tried this.
ContentDefinitionManager.AlterTypeDefinition("Expert",
b => b.WithPart("ExpertPart"));
ContentDefinitionManager.AlterPartDefinition("ExpertPart",
b => b
.WithField("ExpertOf", fld => fld
.OfType("TaxononmyField")
.WithDisplayName("ExpertOf")
.WithSetting("TaxonomyFieldSettings.Taxonomy", "ExpertOf")
.WithSetting("TaxonomyFieldSettings.LeavesOnly", "false")
.WithSetting("TaxonomyFieldSettings.SingleChoice", "true")
.WithSetting("TaxonomyFieldSettings.Required", "true")));
When i run this migration, then go into the content definition of the part. The expert of is not listed under "fields" in the content definition. It it listed under "Parts". You can not get to the taxonomy settings. This is what happens
Also, the content edit screen does not have the taxonomy listed. So i cannot attach the expert part to the taxonomy.
.OfType("TaxononmyField")
– Lawyerson