Update: This can now be found on GitHub: https://github.com/eriknordin/PTB-Helpers
While everyone else is creating cool gadgets for the new site center I was appointed to update an “old” site with some new functionality. And since PageTypeBuilder was introduced in my EPiServer life, and don’t feel like working without it in any project. If this would’ve been a small project I would probably just created the PTB classes by hand, but after looking into the page type list I was freaked out. Therefore I spent some time creating a “plugin” (it’s not a real plugin, just “some” code) that creates PageTypes classes from all the page types and properties in the current project.
The first step is to download the source code, it’s a zip-file containing a .aspx/.designer/.cs
Download it here
Include the files in your project.
Open you web browser and surf to the page.
There are a few values that yo can change before doing the import/export (it’s up to you to define what it is :)).
You can add a prefix before and after the class name, change the base class that the classes should extend, enter a namespace (required) and finally decide where to put the files.
You can also exclude page types that you don’t want to include.
And finally you can decide which namespaces that should be included by default.
When clicking “Create classes” you will see a log of classes created plus if something is excluded.
An example is that every propertyname with a “-” in it will be excluded because you can’t have “-” in a property name in C#.
When the files are created you just have to include them in your project and you should be good to go. You have to remember to include a reference to PageTypeBuilder, and you also need to change so all PageTypes .aspx.cs files inherits from the right class.
One other thing that should be mentioned is that PageTypes names like “[Something] Page Type Name” will end up like [yout catalog]\Something\PageTypeName.cs (if you don’t have any prefix).
Update – 091103 10:23
1. Discovered a bug and updated the source files.
2. Before using this, backup you database, this code is used without any warranty.
3. If you want to extend the functionality, please feel free to do it.
Update – 100128
DefaultValueType was not set which lead to some problems. Fixed.