DFS 11.1 - Configure JSS FieldSerializers
Prerequisite for this guide, you must install the package DAM for Sitecore JSS-11.1.zip
The connector comes with a fieldserializer for each of the 3 custom field types: asset, assetlink and assetlist. The config can be found in the file App_Config\Include\damforsitecore\DFS.JSS.Digizuite.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
<sitecore>
<pipelines>
<group groupName="layoutService">
<pipelines>
<getFieldSerializer performanceCritical="true">
<processor patch:before="processor[@type='Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer.GetDefaultFieldSerializer, Sitecore.LayoutService']" type="DFS.JSS.Serializers.GetAssetFieldSerializer, DFS.JSS" resolve="true">
<FieldTypes hint="list">
<fieldType id="1">Asset</fieldType>
</FieldTypes>
</processor>
<processor patch:before="processor[@type='Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer.GetDefaultFieldSerializer, Sitecore.LayoutService']" type="DFS.JSS.Serializers.GetAssetLinkFieldSerializer, DFS.JSS" resolve="true">
<FieldTypes hint="list">
<fieldType id="1">Assetlink</fieldType>
</FieldTypes>
</processor>
<processor patch:before="processor[@type='Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer.GetDefaultFieldSerializer, Sitecore.LayoutService']" type="DFS.JSS.Serializers.GetAssetListFieldSerializer, DFS.JSS" resolve="true">
<FieldTypes hint="list">
<fieldType id="1">Assetlist</fieldType>
</FieldTypes>
</processor>
</getFieldSerializer>
</pipelines>
</group>
</pipelines>
</sitecore>
</configuration>
Using the Sitecore Layout Services /sitecore/api/layout/render/[config]?item=[path]&sc_lang=[language]&sc_apikey=[key]
. The json output for each of the 3 fieldserializers can be configured. The configuration can be found in the file App_Config\Include\damforsitecore\DFS.Settings.config. The default config looks like this:
<DFS.JSS.FieldSerializer>
<property outputName="assetTypeId" propertyName="AssetTypeId" />
<property outputName="title" propertyName="Name" />
<quality outputName="src" />
<quality outputName="src_download" download="true" />
</DFS.JSS.FieldSerializer>
This is an example of the out for the fieldtype asset.
"DFS Medie": {
"value": {
"assetTypeId": 4,
"title": "Butterfly",
"src": "/dfsmedia/baeefe6b74df44be8a2bccfb2c57af8e/114-50036/butterfly",
"src_download": "/dfsmedia/baeefe6b74df44be8a2bccfb2c57af8e/114-50036/options/download/butterfly"
}
}
Configuration
The section <DFS.JSS.FieldSerializer>
can contain 2 different types tags property
and quality
.
Property tag
These are all the metadata describing the asset.
The following attributes are avaible:
outputName
This is the property name of the json output.propertyName
The properties that can be used are the one fra theAssetMetadata
object DFS 11.1 - 4 Accessing metadata through API
Use the name from the Property Name column. If you want to use some of the dynamic metadata, then insert the guid og the metafield. The avaible metafield guids can be found in the Administration dashboard under the menu “Show settings” DFS 11.1 - Show Settings. Look for the property DynamicMetadata. If you dont see the metafield you want, then it could be that the user to synchronize data between Digizuite and Sitecore does not have read access to the metafield. Please contact Digizuite for futher help.delimiter
This is used for properties with multiple values. The default delimiter is semicolon.
Quality tag
These are the link to the media, can be the source file og the asset or any variant. Can be requested as a download url also.
The following attributes are avaible:
outputName
This is the property name of the json output.qualityId
This is the rendition id of an asset also known as the mediaFormatId. If you want to request the source of the asset, the type source or -1. If you down add this attribute, then the quality that the content editor selected will be used.download
If you want the url to be a donload url, then set this to true.
Examples
Here is a list of different usecases and how the configurations should look like.
I want to get the title of the asset
<property outputName="title" propertyName="Name" />
I want to get the Photograph metafield from my Digizuite which has the guid
baeefe6b-74df-44be-8a2b-ccfb2c57af8e
<property outputName="photograph" propertyName="baeefe6b-74df-44be-8a2b-ccfb2c57af8e" />
I want to get all the folders that the asset is part of. But i want the delimiter to be #
<property outputName="folders" propertyName="bf0ad1a6-984a-494e-a227-9d70c6a864f9" delimiter="#" />
I want to get the media url with the rendition the content editor selected
<quality outputName="src" />
I want to get the media url with a specific rendition from my Digizuite DAM. The rendition is called Small JPG and has mediaFormatId 50036
<quality outputName="src_small" qualityId="50036" />
I want to get the media url for the source of the asset
<quality outputName="src_source" qualityId="source" />
or<quality outputName="src_source" qualityId="-1" />
I want to get the media url with a specific rendition from my Digizuite DAM and make it a download link. The rendition is called Small JPG and has mediaFormatId 50036
<quality outputName="src_small_download" qualityId="50036" download="true" />
Crops
If an asset has crops, then it is posible to get a list of the crops in the json respons. You simply add a property called Crops like this.<property outputName="crops" propertyName="Crops" />
The json output would look like this.