Data Seeding a Content Type

Topics: Customizing Orchard, Writing modules
Sep 6, 2012 at 2:41 PM

Hello,

I am trying to implement a workflow whereby if I were to drop my database a custom module would generate the custom content types and seed with initial data. I have created a recipe to enable and download the required modules and implemented a simple create method within my migrations class.

 

public int Create() {

            ContentDefinitionManager.AlterPartDefinition("TeamMember",
                cfg => cfg
                    .WithField("Priority", bld => bld.OfType("NumericField"))
            );

            ContentDefinitionManager.AlterTypeDefinition("TeamMember",
                cfg => cfg
                    .DisplayedAs("Team Member")
                    .WithPart("BodyPart")
                    .WithPart("CommonPart")
                    .WithPart("TitlePart")
                    .WithPart("PublishLaterPart")
                    .WithPart("TeamMember")
                    .Creatable()
                    .Draftable()
            );

            
            return 1;

 

At this point how can I go about seeding some data, i.e. the title, priority and body copy. I understand that I would need to implement an IRepository to create() but am not sure as to what type this would be and how to enter data into e.g. the BodyPart content area.

Thanks.

Coordinator
Sep 12, 2012 at 7:37 PM

I'm sorry, but I don't see a question here. Why would you need a IRepository? Why not just inject a content manager and use that?