CMS 6 crashes using Page Type Builder
Postad av Erik Wenneborg i Blogg, Erik Wenneborg den 5 mars, 2010
Page Type Builder (PTB) is an open source project developed by Joel Abrahamsson that changes the way of working with page templates in EPiServer quite a bit: “Page Type Builder allows developers to define EPiServer page types in code which eliminates the need to synchronize page types between different servers. As page types are declared in code it also enables inheritance between page types and strongly typed property access.”
Of course we wanted to use PTB and CMS 6 for our new project. We went to work but soon discovered that something did not really work. When looking on our PageTypes in admin mode, some of them caused the UI to crash.
It turns out that the UI for CMS 6 (Admin/EditPageType.aspx) does not accept that the help text for any property is null which is the default value for it using PTB. A quick solution would be to change the EPiServer templates to take care and use an empty string when there is a null value. In practice this means:
Change line 81 in EditPageType.aspx from
<%# EPiServer.Core.LanguageManager.Instance.TranslateFallback("/pagetypes/common/property[@name='" + DataBinder.Eval(Container.DataItem, "Name") + "']/help”, DataBinder.Eval(Container.DataItem, “HelpText”).ToString())%>
to
<%# EPiServer.Core.LanguageManager.Instance.TranslateFallback("/pagetypes/common/property[@name='" + DataBinder.Eval(Container.DataItem, "Name") + "']/help”, DataBinder.Eval(Container.DataItem, “HelpText”) == null ? “” : DataBinder.Eval(Container.DataItem, “HelpText”).ToString())%>
but we do not know if CMS 6 will try to access help text anywhere else without checking for null. So we went on by changing PTB:
In the file
/Synchronization/PageTypePropertyUpdater.cs
in the method
CreateNewPageDefinition
we changed from
pageDefinition.HelpText = propertyDefinition.PageTypePropertyAttribute.HelpText;
to
pageDefinition.HelpText = propertyDefinition.PageTypePropertyAttribute.HelpText ?? "";
and in the method
UpdatePageDefinitionValues
we changed
pageDefinition.HelpText = propertyAttribute.HelpText;
to
pageDefinition.HelpText = propertyAttribute.HelpText ?? "";
Hopefully this will help someone. We will continue to post here if we run in to any other issue that could be of interest along the way.
So far we are very pleased with PTB and CMS 6 working together and we are looking forward to releasing some great sites using them.
