DataType Serializers
Some data types store a reference to a content or media item in their configuration. A content picker's start node, or the folder a rich text editor uploads images to, are both saved as the key of an item in that site.
If you sync content and media between your sites, those keys are the same everywhere, and uSync's data type files work as they are.
If you don't sync content or media, the keys in one site won't match the items in another. The data type imports, but its start node points at something that doesn't exist on the target.
The uSync.Community.DataTypeSerializers package fixes this by swapping those keys for the item's path when uSync exports a data type, and turning the path back into the right key when it imports.
If you sync content and media with uSync or uSync.Complete you don't need this package. The keys already match between your sites.
Installing​
The package is available from v17.4.0 of uSync. Add it to your site from NuGet:
dotnet add package uSync.Community.DataTypeSerializers
There is nothing to register or configure. uSync finds the serializers when the site starts, and uses them the next time you export or import data types.
Once it is installed, run a full export of your data types so the files on disk contain paths rather than keys.
What it covers​
| Data type | Editor alias | Setting mapped |
|---|---|---|
| Content Picker | Umbraco.ContentPicker | startNodeId |
| Media Picker | Umbraco.MediaPicker3 | startNodeId |
| Multi Node Tree Picker | Umbraco.MultiNodeTreePicker | startNode.id, and startNode.dynamicRoot.originKey when a dynamic root is set |
| Rich Text Editor | Umbraco.RichText | mediaParentId (the media folder images are uploaded to) |
uSync's own rich text serializer cleans up the mediaParentId value when it imports, but it doesn't make it portable. This package fills that gap.
What the export looks like​
Without the package, a content picker's start node is stored as a key:
"startNodeId": "a3c2f0e1-5b8d-4c4e-9a6f-1d2e3f4a5b6c"
With the package, it is stored as the entity type and the path to the item:
"startNodeId": "document:/Home/Blog"
Media items use the media type, for example media:/Images/Uploads.
On import, uSync follows the path from the root of the content or media tree, matching each item by name, and puts the key of the item it finds back into the configuration.
The item must exist on the target site, with the same name and in the same place in the tree. If uSync can't find it, the path is left in the configuration as it is.
Renaming or moving the start node item changes the path. Export the data type again after a rename or move.