Enforce version presence
In Sitecore, you can have different versions of an item, for example, different versions of an image or versions of an item in a different language. When an item doesn't have any item versions, and you try to fetch a version of that item, instead of returning NULL, Sitecore returns the non-versioned item. To change this behavior, and enforce the presence of a version, use the Enforce version presence feature. The feature ensures that an item version is returned only if it exists (in a database or resource). By default, enforce version presence is disabled; the setting is configured for each site separately, so it could be enabled on some and disabled on others.
You enforce version presence by first enabling it for the entire website, then configuring it for individual items. You can enable enforce version presence on individual items, or on all items based on an item template, by setting the configuration for the item or item template, respectively.
To enforce version presence:
-
Open the website configuration file (for example, under
\Website\App_Config\Sitecore.config
) and set theenforceVersionPresence
attribute to true. If theenforceVersionPresence
attribute is not present, you can add it manually using a configuration patch file, for example:RequestResponse<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <sites> <site name="website"> <patch:attribute name="enforceVersionPresence">true</patch:attribute> </site> </sites> </sitecore> </configuration>
NoteDon't enable the
enforceVersionPresence
attribute on the shell or any other default site. -
To enforce version presence on an item or template, in the Content Editor, on the View tab, make sure that the Standard fields view is enabled.
-
Navigate to the relevant item.
NoteTo enable the feature for all items that are based on a certain template, apply the setting to the __Standard Values item of the template.
-
In the Advanced section, select the Enforce Version Presence check box.