Thursday, August 25, 2016

Dictionary Domains

http://sitecorecode.com/index.php/tag/sitecore-dictionary-domain/

Our attribute is miss-named.. we're using dictionaryPath, and it should be *dictionaryDomain*

According to (b, we can use the dictionary GUID

Follow below steps to use dictionary domain in your Sitecore website:
  1. 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 store
                Sitecore
                            Content
                                        Site One Node
                                                    Global Settings
                                                                Sample Dictionary Domain
                                                    Home
  2. 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
  3. 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 code
                                Sitecore.Globalization.Translate.Text(“key”);  
         ii.    You can also define dictionary domain in code as shown below                                                                                                  Sitecore.Globalization.Translate.TextByDomain(“Domian”,”Key”);
Must Read:
http://www.sitecore.net/Learn/Blogs/Technical-Blogs/John-West-Sitecore-Blog/Posts/2012/11/Sitecore-ASPNET-CMS-6-6-Features-Dictionary-Domains.aspx

No comments:

Post a Comment