Monday, September 29, 2014

Sitecore Proxies And Clones

A)  Proxies:

Proxy items duplicate’s an item (or sub tree) from one part of the content tree to another. Any Update to proxy item will update the source item and vice versa.


Proxies are generally used when we need an item appear as a child item to multiple parent items. Following example demonstrates a book item appearing under multiple genre items.























Step 1: Set proxiesEnabled element to true in web.config at /configuration/sitecore/databases for master and web databases.

<databases> 
<database id="master" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">    
<proxiesEnabled>true</proxiesEnabled>   
</database>
</databases>

Step 2: Create two new templates “BookCategory” & “Book” with “Title” & “Description” fields.


















Step 3: Create book items from book template in a common folder.


















Step 4: Create “Comedy”, “Fiction” & “Romance” categories from “BookCategory” template.





























Step 5: Create proxy items at /Sitecore/System/Proxies location using /System/Proxy data template.


Step 6: Set the source item and target item of proxy. Here, “Book1” is the source item and “Comedy” is the target item.






















Step 7: Create other proxies as required.





















Step 8: Editing any proxy item would affect source item and vice versa

Publishing a proxy
<publishVirtualItems> setting in web.config indicates whether Sitecore should publish virtual items as if they were normal items.
If this setting is set to true, virtual item becomes a real item and the relationship between virtual item and parent item no longer exist.
If this setting is set to false (preferred), relationship between virtual item and parent item exist even on web database if proxies are enabled on the web database.

B)  CLONES

Cloning creates a dynamic duplicate of an item or branch in the content tree to another different location within the same content tree. A clone inherits field values from the parent item instead of standard values and provides notification to clone item whenever parent item is modified.

If all fields of parent item and cloned item are same, then any change to parent item would apply changes to all cloned items immediately without any prompt.

If the value in the cloned item is different to parent item, Sitecore creates a notification, which the user must accept in order to apply the change to the cloned item.

Cloned items when published, become real items and the relationship between cloned item and parent item no loner exist.

Following steps show an example of creating a clone

Step 1: Select the parent item to be duplicated and click on “Clone” button in the “Configure” section.




















Step 2: Select the destination for the cloned item and click on “Clone” button.




















Step 3: Changing field value in the cloned item will not affect the parent item.










































Step 4: Change parent item field value. Since content of parent and cloned item are different, sitecore creates a notification which user must accept.























UNCLONE: A clone can be converted to a normal item, severing any ties it has to the original and become completely independent by uncloning.


1 comment: