All model properties annotated with Required attribute will be displayed on the Content Create view. Sometimes we would like show some additional properties when creating new content. For example we have a boolean property “Show article on Start Page”. It’s not mandatory to mark it, but it’s could be a useful feature for editor if he could select it when adding new article. I tried to extend EPiServer functionality and add this feature.

Create Content Dialog

Extending metadata information

First I introduced DisplayOnContentCreateAttribute annotation attribute. If model property is marked with this attribute it should appear on the view.

The atribute will be used by custom MetadataExtender. Inside ModifyMetadata method the extender will check if property has DisplayOnContentCreate attribute. Based on this information it will set displayOnContentCreate client property.

And finally I had to register our MetadataExtender in the InitializableModule.

Extending Create View

To use new attribute on the client side I replaced CreateContentViewModel EPiServer script file with custom implementation. I did it using modules.config file …

…then I prepared _hasDisplayOnContentCreate method responsible for checking if content should be displayed on the Additional properties panel.

It is used by two internal methods:

  • _propertyFilter – return the collection of properties that should be displayed on CreateContent view
  • _hasRequiredProperties – checks if content has at least one required property. If no, then panel wan’t be displayed. So displayOnContentCreate property value should be also included in this condition.

After running the solution all properties marked with DisplayOnContentCreateAttribute will be displayed on Additional properties tab.

Using additional properties

Code is available on Gist