When editing complex types like ContentArea or XHtmlString it would be good to have preview of all available property value versions. The Editor would be able to revert the property to older version or copy property from other language or even another page. In this article I will show an extension to All Properties mode that allows reverting property value to a specific version.
Using All Properties compare mode for reverting property
All Properties compare mode is a built-in EPiServer functionality that allows to copy property value between versions.
Editor has to select version to compare and then use “Copy” button to revert specific property. This is fine for copying data between languages and to have an overview of all changes between versions. But to revert single property you need to know in which version it has changed. It can take a while to change the context to compare mode and then find the version where the property has specific value.
Reverting property extension
When using my extension you will see an icon next to any property editor in All Properties mode.
After clicking an icon the dialog with property value history will be displayed.
Grid shows similar information to Versions gadget, but additionaly it has “preview” link on every row. When clicking the preview, property with specific value is displayed.
Filtering grid
The dialog has few filters that simplifies selecting value. By default grid shows versions for current content in current language and only values different than current property value.
Filtering by language
Language dropdown is used to filter content versions by language branch. Editor can change the language and for example copy ContentArea value from Swedish version. When showing all language versions the additional column with language code is displayed.
By default filter is set to current content language.
Showing all available versions
The “Show all versions” filter allows to show all available content versions. When checked, then grid will show:
- empty values
- values same as current property value
- duplicate values
By default filter is unchecked and show only unique values.
Copying property value from another content
The third filter “Selected content” allows to change content used to populate versions. By default it shows currently edited content. Changing this value allows editor to copy property value from another content of same type. It can be especially useful to copy large ContentAreas between pages.
Using functionality on specific properties
By defult icon is displayed for ContentArea, XHtmlString, string, Categories, URL and ContentReferences. For other property types icon won’t be displayed. I thought that it make no sense to show it for example for “boolean” properties. It’s possible to to turn on or turn off reverting property functionality by using “AllowRevertToDefaultAttribute” on property definition.
1 2 3 4 5 6 7 8 |
[AllowRevertToDefault] //defult true public virtual string TestString { get; set; } [AllowRevertToDefault(true)] public virtual bool TestBool { get; set; } [AllowRevertToDefault(false)] // do not allow to revert property on this ContentArea public virtual ContentArea TestContentArea { get; set; } |
Below is a demo of using an extension.
The source code together with working example can be found on github.