Post navigation

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.

If you are using SiteDefinition.config to manage multiple sites then make sure SitecoreCDN.config execute after SiteDefinition.config file. One thing you can do is update name of SitecoreCDN.config by adding prefix “Z” like ZSitecoreCDN.config

CDN Sitecore connector package for Sitecore 7.2 can be downloaded from here

Conclusion – Existing CDN Sitecore connector contains reference of old DLLs and .net framework. By updating reference it will start working with latest Sitecore version

Some time we encounter situation where we are using WFFM to create form but because of custom requirement we don’t want to use Sitecore in-built send mail action instead we want to write our own custom action.
In-built Send Email action editor GUI looks like below -

Figure – 1

We want to update this GUI so that we can hide To, CC, BCC fields because we are not using these fields. Its always good to hide extra fields so that content editor will not get confuse. Now how can we do that? Answer is – follow below steps and you are all set:
1. There is an editor associated with inbuild send mail action. Sheet UI of this editor can be found at “website root\sitecore\shell\Applications\Modules\Web Forms for Marketers\Dialogs\Action Editor\SendEmail.xml” . UI of this editor is shown in fiture-1. First step is to create a copy this UI with name “CustomSendEmail.xml”
2. Open CustomSendEmail.xml file and change tag <SendMail.Editor> to <CustomSendEmail>

Please note – Right now we are only using existing editor code behind class that why we are only hiding controls not completely removing them from xml file. In next post I will explain you how you can create new class for editor

4. Now in Sitecore create a new custom action with name CustomSendEmail under /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions. Update class name for custom action as shown in below image

5.Now update editor name in field “Editor” under section “Editor” with value “Control: CustomSendEmail”. As shown in below image

6. Save Custom save action item and you are all set.
7. Now assign CustomSendMail action to your form and UI of CustomSendMail will look like below.\

Figure-2

Creating a custom action is 2 step process -
1. Create a class under your project in visual studio
2. Create custom action under “/sitecore/system/Modules/Web Forms for Marketers/Settings/Actions” and register custom action created in first step under it.

Some Html CSS tips and tricks Trick No. 1:We often need to use clear in our html so insted of using:<divstyle="clear: both"></div> OR <divclass="clear"></div>

We can make use of pseudo selector :after,like this: ———–

.container {

/*dummy attributes*/

height:100%;

width:100%

margin:5px;

}

.container :after {

display: block;

clear: both;

content: " ";

height: 0;

overflow: hidden;

}

.container childDiv {

float:left;

}

——

It makes more sense if we are using LESS,as we can create a mixin for this as:

.clearfix() {

&:after {

display: block;

clear: both;

content: " ";

height: 0;

overflow: hidden;

}

}

and then we can call this in our class,like this:

.container {

/* this div has two floated child,*/

/* so we must clear left/right after this div.*/

/* calling the mixin,which will take care of clear.*/

.clearfix;

.div1{

float:left;

}

.div2{

float:right;

}

}

Trick No. 2: last-child/first-child are another pseudo selector,which are very useful,so if we want to apply some additional attributes to last/first child of certain class,we can use these selector. This is how these can be used:

.class-name {

/* dummy attributes */

height:100%;

width:100%

margin:5px;

}

.class-name:last-child {

margin:0px;

}

Trick No. 3:To select the next element, we can use + selector:

.class-name + span {

/*dummy attributes*/

height:100%;

width:100%

margin:5px;

}

it will select the next span element. We can also select the next element with class name.

.class-name + .some-class {

/* dummy attributes */

}

Trick No. 4:If we want to make some portion of image clickable (hot spot),then we can insert an anchor with absolute position, e.g.:

.container {

background: url('../images/container-bg.png') no-repeat;

height:75px;

width:75px;

position:relative;

}

.hot-spot {

position: absolute;

bottom:0;

right:0;

height:28px;

width: 28px;

display: block;

content:"";

}

HTML for this

<divclass="container">

<!-- We can place this anchor anywhere under this div -->

<aclass=".hot-spot"href="#"alt="hot spot"></a>

<!-- dummy text -->

<p>

Lorem ipsum dolor sit amet.Etiam a ipsum id purus.

</p>

<div>

Note: if the element is positioned absolute, then its parent must be positioned relative.

Trick No. 5: For browser specific css, instead of creating different css/less files we should use this:

It’s a very simple process, as we need to add content between the language specfic tag e.g., if we want to have content in French then we can add <fr> tag and we can add French content here.

Please note that we have to use language specific tags to enter content in that language. If you enter content of different language under<en>it will replace English language content for an item during import.

When we imported above XML file in Sitecore it will automatically create different language version of Sitecore item present in file. After importing above xml file in Sitecore we can see 4 more languages items gets created for Sample Item. In below image we have select Japanese Version of Sample Item.

Please note that if you don’t specify the language tag<fr> </fr>Sitecore will not detect the language while import.