Create Dynamic Module using the API
Is it possible to create a Dynamic Module without using the Back End Module Builder tool?
Sure, it's possible, but it's a very time-consuming task. I wouldn't recommended it unless absolutely necessary. The documentation explains how to do it.
I was hoping it's possible to do it programmatically. The following code will not work but demonstrates what I am trying to do.
//Create the module.
App.WorkWith().Module().CreateNew(new Guid())
//Set the properties of the module.
.Do(b =>
b.Title = "Testimonials";
b.Description = "Customer Testimonials";
b.ContentTypeName = "Testimonial";
)
//Save the changes.
.SaveChanges();
Hello David,
Currently you can create dynamic modules only from the Sitefinity backend using the Module Builder. You can refer to the following article from our documentation on how to achieve this. You can also check the following video demonstration. Code samples are automatically generated for the dynamic module you have created and you can use it as a sample on how to work with your dynamic module programmatically - e.g. how to create a dynamic module item, to delete a dynamic module item, to get a collection of dynamic module items through filtering and etc.
To view the generated code samples please go to Administration -> Module builder and select your module. Then please click on the Code reference for < module name> link which is on the right-hand side of the page. Here is a screenshot for your convenience.
If you have a specific reason to build your modules programmatically you may take a look at the following articles from our documentation on how to create custom modules in Sitefinity: