Every now and then, often on Twitter, I get asked how to add a property of type LinkItemCollection to a page type using Page Type Builder. First of all, the solution is to use the PageTypeProperty attribute and specify the type of the property to be PropertyLinkCollection. The return type should be LinkItemCollection. Like this:
[PageTypeProperty(Type = typeof (PropertyLinkCollection)] public virtual LinkItemCollection Links { get; set; }
More generally, when you use Page Type Builder you can use any type of EPiServer properties, including third party properties and your own custom properties. However, when you do so you must explicitly specify the type of (EPiServer) property that the (code) property should be mapped to, just like we did in the example above.
When you create properties of the standard (“system”) property types, such as PropertyNumber or PropertyBoolean that isn’t necessary as Page Type Builder will infer the property type from the code property’s return type. You can find a list of these default mappings in this post.
Of course, code properties of type LinkItemCollection could, and should, also be mapped to PropertyLinkCollection by default and I’ll fix that in the next release.
PS. For updates about new posts, sites I find useful and the occasional rant you can follow me on Twitter. You are also most welcome to subscribe to the RSS-feed.
Similar articles
- Default property type mappings in Page Type Builder
- A common problem with Page Type Builder and UniqueValuePerLanguage set to false
- Using XForms with Page Type Builder
- Define tabs in code with Page Type Builder 0.8.5
- How would you like to work with Tiny MCE settings and Page Type Builder?
- Page Type Builder 2 Preview 1 released!
- Developing with Page Type Builder – Inheritance and Specifying Property Types
- Working with Dynamic Properties and Page Type Builder
My book
Want a structured way to learn EPiServer 7 development? Check out my book on Leanpub!
Comments
comments powered by Disqus