PageTypeBuilder, an open source project developed by Joel Abrahamsson is a great tool that helps managing, directly in code, Page Type definitions in EPiServer projects.
As anyone that has worked with EPiServer knows, Page Types are usually managed in the Admin interface, and they do not support advanced features like inheritance. You can use Dynamic Properties to somehow manage content that is shared among different page types in the project, but there isn’t real structural inheritance. Also, to synchronize Page Types between environments (such as when you have your project in a Continuous Integration deployment schema, with environments for Build, QA, Staging, Production, etc.), you have to manually export and import the Page Types in each one, or even worse, copy the entire database from server to server.
PageTypeBuilder easily solves this synchronization issue. All Page Types are defined in code, as any other class in C#. This means that, when you deploy the project to another environment, the Page Types will be automatically synchronized without further intervention. And since they are defined as C# classes, Page Type structure inheritance is as simple as inheriting one Page Type class from another Page Type class. You can even define “Base Page Types” that contain shared data fields; however they aren’t created in the system as actual Page Types. The “concrete” Page Type classes inherit from this Base Page Type class, and implement their own additional fields.
PageTypeBuilder also allows managing Tabs and, since version 2.0, Field Configurations. In upcoming posts, I’ll discuss these features in more detail.
PageTypeBuilder has its disadvantages and limitations. There are not many resources about it in the Internet, but you can always check Joel’s blog for introductions and examples. Also, since it creates the Page Type structures in the project’s database when first accessed, it doesn’t delete fields or Page Types that have been removed from the code. You will have to delete them manually in Admin mode.
In an upcoming blog post, I’ll give a simple example of how to create a simple Page Type hierarchy demonstrating inheritance and property configuration.