Quantcast
Channel: Brian Pedersen's Sitecore and .NET Blog
Viewing all articles
Browse latest Browse all 286

Sitecore Item Clones is only a thing in the master database

$
0
0

The Sitecore item cloning is a technique in which you can create a copy of an item that inherits the field values of the original items.

In the latest versions of Sitecore (at least from 9.0 and forward) you can ask if an item is a clone:

Database master = Database.GetDatabase("master");
Item item = master.GetItem(someGuid);
bool isClone = item.IsItemClone;

But please notice that the Item.IsItemClone will always return FALSE if you request the item from the WEB database:

Database web = Database.GetDatabase("web");
Item item = web.GetItem(someGuid);
// This value is always false
bool isClone = item.IsItemClone;

This is because the Source and __Source Item fields of an item are the fields on the original item that tells Sitecore that this item is cloned:

Clone from Master database

Clone from Master database

… is not copied to the WEB database when published:

Clone from Web database

Clone from Web database

This is by design. If you would like to know if an item is a clone (to avoid duplicate items in your sitemap, of when creating canonical URL’s, for example), you will need to code a solution yourself.

MORE TO READ:


Viewing all articles
Browse latest Browse all 286

Trending Articles