Field labels in Sitecore are next to each field and are shown by default if the user is an Administrator. Labels show how the field value will be used based on the languages, versions, and type of item that is using the field.
Where are the Field Labels located in Sitecore?
Field labels are shown next to each field if the field value is used in a certain way. The field value will be blank if it is coming from the item itself.
What are the different types of field labels in Sitecore?
Here are all of the different types that are possible in Sitecore 9.1.1. “English” is used as an example in the fallback value types below but could be in other languages.
- [shared]
- [unversioned]
- [shared, standard value]
- [shared, original value]
- [unversioned, standard value]
- [unversioned, shared, standard value]
- [unversioned, shared, standard value]
- [fallback value (English)]
- [fallback standard value (English)]
Why don’t I see a label next to my field in Sitecore?
It could be one or both of the reasons below:
- The field doesn’t have a label because the field value is coming from the item language and version currently selected.
- You are not an Admin, so you will not see the field labels by default. You can change this by updating the setting below to “true.”
<!-- CONTENT EDITOR SHOW FIELD SHARING LABELS Determines whether or not the Content Editor displays field sharing labels ([shared] and [unversioned]) to users that are not Sitecore administrators. Default value: false --> <setting name="ContentEditor.ShowFieldSharingLabels" value="false"/>
What do the different field labels in Sitecore mean?
- Shared means that the field value will be shared among all of the languages
- Unversioned means that the field value will be used among all of the versions
- Shared and Unversioned come from these 2 checkboxes that are checked in the template of the page. Just uncheck and save either one or both to remove the label from the field.
- Original Value means that the field value is coming from a clone. You can read more about it here.
- Standard Value means that the field value is coming from the template and not from the item itself. You can read more about it here.
- Fallback Value means that the field value comes from the fallback language item and not from the language currently selected for the item itself. You can read more about it here.
Where is the code so I can see how it works?
- Sitecore.Shell.Applications.ContentEditor.EditorFormatter.RenderLabel
- found under Sitecore.Client.dll
- code shows how the field labels are rendered
- Sitecore.Data.Fields.Field.GetLabel
- found under Sitecore.Kernel.dll
- code runs the getFieldLabel pipeline directly
The pipeline that is used for rendering the field labels can be found here
<getFieldLabel> <processor type="Sitecore.Pipelines.GetFieldLabel.ResolveFieldLabel, Sitecore.Kernel"/> </getFieldLabel>
Is there a way to get the labels per field programmatically?
I created a Powershell script below so further testing could be done. If the field doesn’t currently have any labels, then the result will be blank. You might need to change the path, language, or version variable in the code below to see the field labels for your field.
<# Simple example to get the field labels #> ############################################################## # Variables (Change this variables to get the results you want) # Field Name $fieldName = "Title" # Item Path $itemPath = "/sitecore/content/Home" # Item Language $langName = "en" # Item Version $versionNum = 1 ############################################################## # Main # Item where the field exists $item = Get-Item -Path $itemPath -Version $versionNum -Language $langName if($item -ne $null) { [Sitecore.Data.Fields.Field]$field = $item.Fields[$fieldName] if($field -ne $null) { # Get the Template Field $templateField = $field.GetTemplateField() Write-Host "Shared = $($templateField.IsShared)" Write-Host "Unversioned = $($field.Unversioned)" Write-Host "Original value = $($field.InheritsValueFromOtherItem)" Write-Host "Standard value = $($field.ContainsStandardValue)" Write-Host "Fallback value = $($field.ContainsFallbackValue)" if($field.ContainsFallbackValue) { Write-Host "Fallback standard value = $($field.FallbackValueSource)" } Write-Host "Fallback value language = $($field.IsValidForLanguageFallback)" # Show the Field label $fieldLabel = $field.GetLabel($true) Write-Host "$($field.Name) label = $($fieldLabel)" } else { Write-Host "$($fieldName) does NOT exist under the item" -f red } } else { Write-Host "Item does NOT exist" -f red }