By Sitecore Coder to Sitecore Coders

Menu

Monthly Archives: September 2014

Purpose of this article is to explain new developers how to properly used dictionary domain. Good technical explanation of dictionary domain can be found here

Sitecore 6.6 introduces the concept of dictionary domains. In any database, you can create any number of dictionary domains, which are items based on the System/Dictionary/Dictionary Domain data template. On each dictionary domain you can specify the fallback domain. If certain key is not found in site specific dictionary domain then program will search key in fallback domain.

Follow below steps to use dictionary domain in your Sitecore website:

Based on your Sitecore content tree structure create item of template “/configuration/sitecore/sites/site”. We normally use below structure in our project where we organize different sites in different folders in case of multi-site environment (you can use same structure for single website as well) and each site contains 2 node under it. One is used to store global setting (Used to store all global meta data used on different pages of website like header, footer) of this website and other is home item under which all pages of website get storeSitecoreContentSite One NodeGlobal Settings SampleDictionary DomainHome

Under dictionary domain folder you can add dictionary entries. You can create folder as well under dictionary domain to organize dictionary entries in logical structure. You can also nest dictionary domains

Once dictionary domain structure is created in Sitecore content tree next step is to use dictionary in layout or sublayouts. There are two ways to use Sitecore dictionary

i.Define Dictionary domain in Sites setting in web.config. a. With this approach open web.config file and add dictionary domain attridute (dictionaryDomain=”Sample Dictionary Domain”) to your managed sites (/configuration/sitecore/sites/site) b. dictionaryDomain attribute in web.config could be name of dictionary domain or GUID of dictionary domain c. Use below code to get dictionary phrase using key in codeSitecore.Globalization.Translate.Text(“key”);

ii. You can also define dictionary domain in code as shown belowSitecore.Globalization.Translate.TextByDomain(“Domian”,”Key”);

As with any other pipeline, you can add processors to, remove processors from, and override processors in the getTranslation pipeline. For example, when porting an existing ASP.NET site into Sitecore, you could add a processor that looks for entries in the resource files from the old site if no entry for a key exists in the Sitecore dictionary system.