A new way to work with tabs

If no tab name was specified the property would be put on the first tab, usually the one named Information. This is still the case but the way to explicitly specify a tab for a property has now changed from specifying a tab name to specifying a type. The type must inherit from an abstract class in PTB called Tab. It must also be concrete. Both of these requirements are validated at start up.

Creating tabs

When you inherit from Tab you must implement three properties, Name, RequiredAccessLevel and SortOrder. By doing so you gain the same control over a tab as you get in EPiServers admin mode. An example tab can look like this:

Note that the key used to identify tabs is the name. This means that you can define the standard tabs, such as Information, Advanced and Categories in code by creating tab classes with the same name. One caveat of this, which follows the same pattern as for page types (unless you specifiy a GUID) and page type properties, is that you can’t rename a tab from code. To do that you should first rename it in admin mode and then in the code.

Other changes

This release also features a fix for a bug in version 0.8 which caused the startup validation of page types to fail if you had a automatic property that wasn’t virtual, even though it didn’t have a PageTypeProperty attribute, in a page type class.

I’ve also renamed the GetTypeForPageType method in PageTypeResolver to GetType and added a new method to the same class, GetPageTypeID. GetPageTypeID takes a type as parameter and returns a nullable int with either the corresponding page type ID as value or null. While nothing in PTB requires this method I found myself needing it recently when I was creating a custom page provider.

Feedback

As usual I greatly value any and all feedback. This time, in preparation for version 0.9, I would especially like feedback about what exceptions those of you who are already using PTB are getting at startup so that I can put in validation for those things and make PTB throw exceptions with more explaining messages.

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more