I'm using Piranha cms in one of my projects.
I'm looking for a solution to automatically add all my page types to page Type Builder.
At this moment my startup Configure method look like this:
var pageTypeBuilder = new Piranha.AttributeBuilder.PageTypeBuilder(api)
.AddType(typeof(Models.BlogArchive))
.AddType(typeof(Models.StandardPage))
.AddType(typeof(Models.StartPage))
.AddType(typeof(Models.RegisterPage))
.AddType(typeof(Models.ApprovePage))
.AddType(typeof(Models.LoginPage))
.AddType(typeof(Models.MyOfferListPage))
.AddType(typeof(Models.OfferListPage))
.AddType(typeof(Models.OfferDetailPage))
.AddType(typeof(Models.OfferCreatedPage))
.AddType(typeof(Models.OfferAcceptPage))
.AddType(typeof(Models.BooksPage))
.AddType(typeof(Models.PropertyPage))
.AddType(typeof(Models.PropertyListPage))
.AddType(typeof(Models.MyBidsPage))
.AddType(typeof(Models.AgendaPage))
.AddType(typeof(Models.ProfilePage))
.AddType(typeof(Models.CheckoutPage))
.AddType(typeof(Models.BidCreatedPage))
.AddType(typeof(Models.ForgotPasswordPage))
.AddType(typeof(Models.ContactPage));
pageTypeBuilder.Build()
I would like to reduce it, if it is possible. Someone can help me?
If you have an up-to-date version of Piranha, you can now do the following.
new ContentTypeBuilder(api)
.AddAssembly(typeof(Startup).Assembly)
.Build();
This will import all of the available content types in the specified assembly. Also, if you have content types in several assemblies, you can add several AddAssembly
calls one after another, just like with AddType
.