Sitecore Content Editing Part 5 – Good Ol’ Times

Content authors Sitecore Sitecore Content Editing Blog Series

After showing you publishing and its gotchas in Sitecore, I want to give you a deeper insight into languages and versioning.

As usual, this blog post is available in German and English to help as many people as possible.

Let’s jump right in!

Versioning in Sitecore

Before diving into versioning, we should quickly recap the basic concepts. Sitecore uses items and templates, with templates being the blueprint for the items. Each template contains a list of fields, which are reflected in all items of that template. Adding a new field to the template automatically also adds it to all the items. Sitecore supports quite a lot of different field types and 3 different field “behaviours”: versioned, unversioned and shared. Note that these behaviours are mutually exclusive.

  • Versioned
    This is the default behaviour. Each field can have multiple versions in multiple languages. There can be an arbitrary number of values for that field, since the English content of version 2 is different than of version 1 and the English version 1 differs from the German version 1.
  • Unversioned
    The field still has different language versions, but only one version per language. Hence, the number of different field values is limited by the number of languages in your solution.
  • Shared
    The field value is the same across all languages and versions.

To give you an impression of how these fields work, I created a template that contains each of the field behaviours.

Versioning Example Template

I then created an item of that type directly under the Habitat root.

Versioning Example Item

You can already see some interesting behaviours of Sitecore:

  • Sitecore gives you a hint what behaviour each fields has. If there is no hint, the field is versioned.
  • Sitecore automatically creates a version of the Item in the language you create the item in.

We can actually remove the version we just created by clicking Remove in the Versions Ribbon.

Remove Version

Note that the item still exists, so we found another notable Sitecore behaviour:

  • An item can also exist without any version.

For now, let us create 2 new English versions by using the Add button in the Versions ribbon.

Add Version

Let us then add content to version 2 of all of the fields, so we can investigate their behaviour.

Filled Version 2

When we change to version 1 now, we can see how Sitecore handles the fields.

Filled Version 1

There is a lot of interesting stuff going on here, so let’s go through it step by step.

  • We can see that the versioned field is empty, so it was not influenced by our change in version 2
  • We can see that the field contents of  both the unversioned and shared fields of version 1 changed when we changed version 2
  • We see a warning that our version will never be visible on the website, as well as a publishing warning in the quick action bar. This means two things:
    1. Only one version of the item can be published at any given time
    2. Always the latest version will be published

Let us now create a German version to confirm our assumption of how the fields look there. Note that the easiest way is to first change the language and then add a new item using Sitecores suggestion.

Create German Version 1 German Filled Version 1

As you might expected, only the shared field is already filled, while the versioned and unversioned ones are still empty.

Version Comparison

Let us switch back to English and look at a very helpful feature: Version comparison (Versions -> Compare).

Version Compare

You can use this feature to see what changed between versions. This is very helpful when you have a lot of fields and especially for rich text fields.

Translating

There is a similar functionality for language comparison, which targets translators. The translation functionality is more like a mode, so let us activate it by choosing Translate from the Version ribbon.

Translate

You can see that the input fields in the content area are now split into two columns. To actually use them properly, we have to switch to German now.

Translate to German

Now this functionality really makes sense! The content author can now see the English version of an item (in read-only), while being able to input German content – Perfect for translators.

To use this feature in an optimal way, adhere to the following rule: Language versions of items should be translations. If you have a different logical content, you should create a separate item.

Excursion: Standard Values

Before showing you the Reset Fields functionality, I will quickly talk about Standard values. Standard values are a nifty Sitecore feature that optimizes how you can deal with empty fields. They allow to define a fallback value which is used whenever a field does not contain any content. To define standard values, we select the template, select the Options ribbon from the builder and click Standard values.

Create Standard Values

Sitecore now creates an item with the Name __Standard Values under the template itself. We fill the fields with some texts and save.

Standard Values

Reset Fields

Resetting fields means to delete the content of these fields. When we go back to version 2 of our English item with standard values in place, we don’t really see a difference. This is due to the fact that we actually filled all the fields. Let us reset all of them now to see what happens. To do so, start the Reset Field Values dialog via the Reset button in the Versions Ribbon.

Reset Fields

This dialog gives you a preview of what each field looks like when you reset it. We want to reset all three fields and check how the item looks afterwards.

Reset Field Values Dialog Standard Values Fallback

You can see that all the fields contain the content of the Standard values item now. Sitecore also gives a hint that the value you are seing is the standard vaue of that field. What makes this concept so powerful is that a change in the standard value of a field is reflected in all of the items.

The difference between nothing and nothing

You might ask yourself why you have to go through the hazzle of the reset dialog, when you can simply delete the text in the fields. When you try that, you will see that the standard value is actually not taken over. Instead, the field is empty.

Empty Field

The reason for that is that Sitecore differrentiates between an empty field (null) and a field that contains an empty string. If it did not, you would have no chance of overriding a standard value with an empty string. So here is your guidelines for the field values:

  1. If you want a field to contain an empty string, delete the contents of that field. The value will not be influenced by changes in the standard values.
  2. If you want a field to contain the standard value, use the reset dialog. The field value will fallback to the standard value and change when the standard value changes.

Versioned Media Items

Media Items can be versioned in Sitecore as well. The functionality to create versioned media items might be a little hidden, but every content author should be able to create them. To show you the differences in using them, we add two more fields to our versioning example template, a versioned image and a shared image.

Image Fields

To have some images available, we upload some demo images that we can use later. For the first image, I use the regular way via Upload file.

Upload File

Sitecore uploads files as unversioned media items by default, so all our media-related fields are shared. You can also see that the template is in a folder called Unversioned.

Unversioned Media Item

If we want to use a versioned media item, we have to go via the Upload files (advanced) dialog and check the Make uploaded media items versionable option.

Upload File Advanced

The resulting media item now is versioned.

Versioned Media Item

I renamed the two items, so that we can distinguish them. When I create a German version of these items and compare them, you can see that the unversiond item seems to be okay, while the versioned item is kind of broken.

Comparing Media Items

The reason is that our versioned media item does not have any content in the relevant media fields. We can add some using the Attach function of the media field. Note that all fields related to the media are automatically filled. I upload a picture of my collague Iulian so that we see a difference between the languages. You would attach a file that e.g. contains a German caption in the image.

Comparing Media Items - Fixed

That looks better. We have two working items, a versioned and an unversioned one. To see how we can utilize those, we go back to our versioning example item and choose the unversioned image in the Versioned Image field and the versioned image in the Shared Image field.

Versioned vs Shared Image

This is kind of expected. Switching to German shows the difference between the approaches.

Versioned vs Shared Image - German

While the versioned field is empty (since we never selected any image for German), the shared image field shows the German variant of our versioned image. You will have to decide which variant is fitting for you.

Option 1: Versioned Image Field

To use different images for different languages, you can use a versioned image type field. You then just select a different unversioned image item for German than for English.

Option 2: Shared Image Field

The second option is easier for content authors. When using a shared image type field, it is best to use a versioned media item. Sitecore will determine which version of the image to show. A drawback is that linking to another image influences all other versions of the linking item.

This concept applies for all reference types (or Link types as Sitecore calls them). Sometimes you want to reference different items with a versioned link field, and sometimes you want to have a shared field referencing a versioned item.

That’s all folks

So much for languages and versioning. Stay tuned for more!

No Thoughts to Sitecore Content Editing Part 5 – Good Ol’ Times

Comments are closed.