Sitecore Data Reuse

Post on 24-Feb-2016

55 views 0 download

Tags:

description

Sitecore Data Reuse. Dan Solovay Lead Web Developer Grand Circle Travel November 16, 2011. Why Reuse Data?. Easier navigation Consistent site experience Information architecture Managing change. Data Reuse Options. Aliases. Simple to implement SEO impact Multi-site issues. - PowerPoint PPT Presentation

Transcript of Sitecore Data Reuse

Sitecore Data Reuse

Dan SolovayLead Web DeveloperGrand Circle TravelNovember 16, 2011

Why Reuse Data?• Easier navigation• Consistent site experience• Information architecture• Managing change

Data Reuse OptionsAliases• Simple path for deeply nested item.

Proxies• Two items with the same content.

Clones• Managed copies, built on standard values model.

Wildcards• Use server side logic to determine item.

Aliases• Simple to implement• SEO impact• Multi-site issues.

Creating an Alias• Add to /Sitecore/System/Alias.• Name of item is alias value.• Data contains link to item to display.

Canonical Links• Get the context item URL.• Put a link in the HTML <head> element like this:• <link rel="canonical"

href="http://www.example.com/product.php?item=swedish-fish" />

• Canonical links should be evaluated in all data reuse scenarios.

Aliases and Multi-Sites• Alias appears under

all site roots.• Path always points

to the original item.• Site name points to

the site root in the URL.

Proxies• Same content item exists in two locations.• The proxy item gets a different ID.• Performance impacts.• Deprecated in Sitecore 6.4.• Some features not yet in clones.

Enabling Proxies• Proxies are not active by default. To enabled them, make the

following changes to Web.config.• To activate, set <proxiesEnabled> to true in the master

database node.• To publish proxies as normal items:• Set <publishVirtualItems> to true in the master node.• Set <proxiesEnabled> to false in the web node.

• To publish proxy definitions only:• Set <publishVirtualItems> to false in the master node.• Set <proxiesEnabled> to true in the web node.

Creating a Proxy• Defined in /Sitecore/System/Proxies. • Define original item, and location for new items.• Select Entire Sub-tree, or Root Item Only• For cross database proxies, use DB name as defined in

configuration, and use item GUID for selected item.

Proxy Behavior• Proxies show on screen with gray text.• Changes flow both ways.• Only difference is Item ID.• Proxy changes are missed by Incremental Publish.• Proxies do not handle deletes consistently.

Proxy API calls• From SDN:• To access the ID of the source item from a virtual item, use:

Item.InnerData.Definition.ID• Item.RuntimeSettings.IsVirtual: - Indicates whether the item is a

virtual item.• Item.RuntimeSettings.IsExternal: - Indicates whether the source

item is from a database other than the target database.• Item.RuntimeSettings.OwnerDatabase: - The database that owns

the source item. Note the Item.Database property will always return the target database.

• It is also possible to enable and disable proxies programmatically.• bool Sitecore.Context.ProxiesActive

Enable (set to true) or disable (set to false) proxies for the current session.

• Sitecore.Data.Proxies.ProxyDisabler Disable proxies for a block of code.

Clones• Manage change between copies.• Clone changes with its source, or goes its own way.• When the source item is deleted, the clone is promoted.• Example: An item tree is moving, but needs to appear in two

places during the migration.

Adding a Clone• Requires read access to Clones ribbon chunk. Currently only

Admin sees it.

• The only input is the location of the new item(s). • Clone Relationship is defined in __source field.

• As of 6.4.1, build 3, clones are version agnostic.

Reverting a Clone Field• Clones will show “original value” next to fields inherited from

the source, rather than “standard value”.

• Use Reset ribbon action and field.Reset() method to revert to Clone value.

• Revert screen has a bug, showing Standard Value instead of Original value.

Clones and Uncloning• Unclone, to make a clone a regular item.• Deleting a source item also works the same …• … in theory. We have seen this break at GCT, so we follow a

Unclone then Delete process.• This is useful for content migrations.

Clone Notifications• Notifications for overriden fields:

• Stored in Notifications table. • Many different workflow options.• Security implications—use inherited security to lock clones.

Clones and Publishing• Changes in source items do not cause clones to go to

PublishingQueue, so they are skipped by Incremental Publish.• Clone changes are picked up by Smart Publish, even though

the Revision Guid field is not changed. Sitecore has dedicated logic to push them through.

• When clones are published, they become normal items.

The Clone API• Item.IsClone• Field.Reset to set a field to the source value.• Item.GetAllClones is private, but the logic is documented on

SDN: http://sdn.sitecore.net/SDN5/Forum/ShowPost.aspx?postid=34012

• Field. InheritsValueFromOtherItem indicates whether the field inherits form its source. (compares to Field.InheritsFromStandardValues)

• Database.NotificaitonProvider.GetNotifications(Item clone) gets notifications of conflicting source field-level changes.

Wildcards*• Asterisk item matches any

unmatched content.• Matches any unmatched path—

up to developer to parse the URL.

• Content is not duplicated.• Keep items in one place (e.g.

Repository), reference via a Selection field.

• Allows flexible handling of content relationships.

• Can be used to display external data (e.g. books by ISBN number)

* Are probably best.

Conclusions• Aliases provide a simple solution to

item reuse.• Proxies should be avoided for

performance reasons, and are deprecated.

• Clones provide a nice mechanism for data migration, but are conceptually complicated.

• Wildcards are more difficult to implement initially, but lead to a simpler tree and avoid complicated workflow issues.

• Massive is coming. what does this mean for data reuse?

To Learn More…• Data Reuse:• http://sdn.sitecore.net/upload/sitecore6/64/reusing_and_sharing_data-usletter.pdf• http://adeneys.wordpress.com/2011/07/01/virtual-items-in-sitecore/

• Aliases• Creating a canonical URL: http://

stackoverflow.com/questions/6919116/how-to-check-whether-sitecore-item-is-using-alias

• Canonical Links:• http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

• Proxies• http://sdn.sitecore.net/Articles/Administration/Using%20Proxy%20Items%20in%20

5,-d-,3.aspx

• Clones• http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Post

s/2010/10/Sitecore-CMS-6-4-Cloning.aspx• Wildcards• http://

www.sitecore.net/Community/Technical-Blogs/Getting-to-Know-Sitecore/Posts/2011/09/Wildcards-and-Data-Driven-URLs.aspx

Thank you!• Dan Solovay• Lead Web Developer, Grand Circle Travel• dsolovay@oattravel.com• dan-explorations.blogspot.com• @DanSolovay on Twitter