Wednesday, July 27, 2016

Sitecore WaterMark Image Generator Module

Adding Watermark or Copyright Info in Sitecore Image? , Yes this module will help you to generate the watermark text on the image.

Prevention is better than cure!

Image is the big asset of any website but on the webpage/website anyone one can download and use your valuable images, do you want to protect your image? The question is how? There are a couple of techniques we can adopt to safeguard our copyrighted content and prevent people from doing so.

One of them is watermarking our images with our logo or watermarking the website name on the images. Yes, this module will help you to generate your company logo or any text on the image so the image would generate as the watermarked image on the fly. 

If you are selling the images on your website or image is the key component on your website then this module is the best fit for you.

In this module, I proposed a watermarking the image using some predefined configuration in sitecore. I have extended the existing JPEG and Image template to support the watermark image generator.

This module has below features

  • Generate on the fly text on image called watermark image
  • Preview the watermark image using preview and edit mode.
  • We can change the property of watermarked text like font, style, color, position, opacity etc.
  • Reflecting on web database and preview/edit mode only
  • Base image will not impacting which is in master database.

Using this module you can customize the watermark text on image as below
  • Font size
  • Font position
  • Font color
  • Font opacity
  • Font style
  • Font family

·     Below are some screen shot of this module:

WaterMark Template:

Water mark image with Live mode

Water mark image with preview mode

How to use this module:

  1. Install this module
  2. Follow the post installation steps
  3. Fill the entire configuration fields in image template
  4. Checked the ApplyWaterMark checkbox
  5. Delete the media server cache from /Website/App_Data/MediaCache
  6. Clear your browser cache and do hard refresh the page (Ctrl and press F5)
  7. If still not reflecting check the color code and provide some other color code.

Post Installation Step for this module:

Add the new WaterMarkImage template ({06B6240C-7E77-4F78-B584-123D5C364D42}) in below exiting template in base template field as a base template.
  •          /sitecore/templates/System/Media/Unversioned/Image : {F1828A2C-7E5D-4BBD-98CA-320474871548}
  •          /sitecore/templates/System/Media/Unversioned/Jpeg : {DAF085E8-602E-43A6-8299-038FF171349F}

Steps to add the new template called WaterMarkImage
  •         Go to the template /sitecore/templates/System/Media/Unversioned/Image : {F1828A2C-7E5D-4BBD-98CA-320474871548}
  •         Go to the base template field and select one more template called WaterMarkImage (/sitecore/templates/Common/WatermarkModule/WaterMarkImage : {06B6240C-7E77-4F78-B584-123D5C364D42}
  •         Same as with /sitecore/templates/System/Media/Unversioned/Jpeg : {DAF085E8-602E-43A6-8299-038FF171349F} template

Publish the below Items with sub-item:

  •         /sitecore/templates/System/Media/Unversioned/Image : {F1828A2C-7E5D-4BBD-98CA-320474871548} 
  •          /sitecore/templates/System/Media/Unversioned/Jpeg : {DAF085E8-602E-43A6-8299-038FF171349F}
  •          /sitecore/templates/Common/WatermarkModule: {9842A1CB-549F-4FC7-BB33-64589DD02D3F}
  •          /sitecore/system/Modules/WaterMarkImage : {B50992CA-51AD-4002-92A5-464E132412AC}

Note: If your web database name is different from “web” then override in below item:

/sitecore/system/Modules/WaterMarkImage/WebDatabaseName: {7DACF478-EDBB-4504-9152-8F691E610821}

Important: if changes are not reflecting (bookmark image) you can try the below:
  •          Clear the media cache from server (/Website/App_Data/MediaCache)
  •          Clear the browser cache
  •          Check the color code in the template, sometime we are using black color in dark image, try to change the color code.
  •          Refresh the page using CTRL+f5

My Sitecore Habitat Architecture Experience !!

Flexibility, Simplicity, Extensibility - Habitat Sitecore Framework

Recently I got an opportunity to go through the sitecore habitat website architecture for one of my new excited sitecore project.

I already heard a lot about sitecore habitat, and after reviewing it, I can say this is one of the best modular architecture/Design/framework/principles/code guidelines by the sitecore.

“Modular Architecture is exactly what you think it is — a way to manage the complexity of a problem by breaking them down to smaller manageable modules. The difference is, as a software architecture style, it has some guidelines, principles and patterns”

Sitecore habitat is the best design/implementation example for modular architecture pattern; here developer can learn how to create the best sitecore architecture for enterprise level projects.

Habitat picked the best market tools in the architecture like:

  • Css Extension Language Sass
  • Package management: NuGet, Node (npm) and Bower
  • Sitecore tools: Sitecore Instance Manager and Sitecore Rocks
  • Build scripts: Gulp
  • Item serialization: Unicorn 3
  • CI server: TeamCity
  • Unit tests: xUnit

First of all, I would like to thanks Martina Welander for this nice video, which explain how to install and configure Sitecore habitat.

Here I am sharing my experience when I installed/configured the habitat site.
I configured the site with different domain and host name called 

Below are some hiccups that I faced during the sitecore habitat site installation:

Unable to install “npm install” command

This is the first issue I faced because IP is blocked in my proxy network, so if you are working under proxy, kindly update it, or try to install NPM package on open network.

NOTE: first you need to install node.js installer in your project source code location.

Build Failed:

Initially my build failed for Sitecore.Foundation.Forms because I didn’t install WFFM package, install the package and run the Copy-Sitecore-Lib command to resolve this issue.

Permission issue:

I faced permission while I run the publish-all-project command

After giving the full permission to my website folder, it worked.

Now time to sync the item in sitecore through UNICORN, 

Kamsar made the developer life easily to build the sitecore best serialization tool called Unicorn” with free of cost, Thanks Kamsar for such a nice product.

After sync the Habitat project item into the sitecore, all serialize item came to my master database but somehow it’s didn’t published automatically, so I published manually.(you can publish manually if not appears in web database)
Everything worked fine in preview mode but once I checked with live mode(web database) it through the below error:

Value cannot be null. Source File: C:\websites\\src\feature\Demo\code\Repositories\OutcomeRepository.cs    Line: 66

As xdb is not installed in my application that’s why this error occurred, the quick turned around I  found to disable the xdb setting from the below configuration

Go to > \Website\App_Config\IncludeSitecore.Xdb.config
And set the value of <setting name="Xdb.Enabled"> and Xdb.Tracking.Enabled to false like below

Everything worked fine now; oops I found one more issue

All links are targeting on host name but I configured my domain as habitatlocal and changed my all the setting as well.

My host name is different from but still somehow it’s used in the link manager all links are generated with prefix host name it means internally somehow its take this host name but I have changed the host name entry in publishsettings.targets file as defined in gitub installation guide.

To solve this problem, I found the quick workaround to add one more host entry in my website binding:

And add the host name in host entry under c:\Windows\System32\drivers\etc\hosts

Now I can browse my site properly

Below are some screen shots:

Happy Sitecore Habitat

I hope it will help you, if you face some issue; feel free to comment your thought or suggestion.

Saturday, July 23, 2016

Check your Sitecore Pipeline/Processor Performance

Is your website running slow? You hooked lots of pipeline/processer in your website may be this is one of the reason of slowness.

How you check the sequence of your pipeline/processor and processing time?

We inject lot of processor/pipeline over the period of time, as per the custom requirement of the project resulted increase the custom configuration files which include custom processor/pipeline patches like after/before or some override the existing pipeline, so the question is how to see consolidate view of your pipeline/processer?

So the all problem is solved by the Sitecore hidden GEM called Pipelines.aspx Page profiler which is available under Website\App_Config\Include\pipeline.aspx

You can hit this page http://sitecore8/sitecore/admin/pipelines.aspx (change your instance name)
By default this is disable like this:

ashish bansal

To enable this renaming the /App_Config/Include/Sitecore.PipelineProfiling.config.disabled file to Sitecore.PipelineProfiling.config

 <configuration xmlns:patch="" xmlns:set="">  
       Specifies whether or not pipeline profiling is enabled. When it is enabled, a profiling snapshot is available   
       at /sitecore/admin/pipelines.aspx.  
       Default value: true  
    <setting name="Pipelines.Profiling.Enabled" set:value="true" />  
       Specifies whether or not the pipeline profiler measures CPU usage. Measuring CPU usage adds a performance overhead  
       to the pipeline but provides additional information about the behavior of the processors.  
       Default value: false  
    <setting name="Pipelines.Profiling.MeasureCpuTime" set:value="false" />  

And set the value true of below setting for gathering more information
<setting name="Pipelines.Profiling.MeasureCpuTime" set:value="true" />

Now hit the URL:

You can check all pipeline/processor are captured in this report, including the custom processor like Diagona.

Below is the explanation of the profiler parameters:

This profiling page data is very useful to pinpoint the processors/pipeline spending most of the time and improve performance by optimizing those specific processors.

I hope you like this blog; feel free to comment your thought or suggestion.

Happy Sitecoring J

Tuesday, July 19, 2016

Sitecore CopyField Tokenizer Module


Copyfield tokenizer module will help you to copy the field’s value with the help of token. You need to set the token as fieldname with prefix of $ in the fieldvalue like default sitecore field token. It’s a best practice to set in the standard value of the template.

We have given one customized button in the ribbon called “Copy Field Value” with the help of this button; you can replace the field name token with field value.

Scenario; that we have the multiple fields in the template with same values like
  • Title
  • Breadcrumb title
  • Page title
  • Sometimes other fields that required the default value as “Title”

So In this scenario content editor need to copy the content from one field to another manually, and if the field type are RTE or IMAGE then it became time taken process.

So just thought about the automation this process so content editor life became easy for this task.

I created this module which is capable to copy the field values based on token, all we need to do to set the template standard field value with base field name as a token.

Let suppose I need to copy the field value from ”title Field” to breadcrumb title and page title field so in this case I need to set the standard field value of breadcrumb title and page title field as below:

Then go to the item, populate the title field value and other fields and press the “copy filed value” button from the ribbon, so it will replace the fieldname token with field value.

In this example we have base fields called title (single line), text (RTE), and image (Image).
And we want to copy these field in the breadcrumb title,page title,page Image fields.

So we filled these value as $title, $text, $Image, so that it can be replace with token field value.

Just have a look of item:

Title, Text, Image fields has been filled with data.

Breadcrumb Title, page title, page Image fields has been filled with standard field value tokens

After click on Copy field value button, token has been replaced with field value:

How to use this module:
Go to template and set the tokens in the standard field:

How to create the token:
$ + FieldName : for example you want to copy from Title field so token would be $Title


I Hope this article will help.

Happy sitecoring :)

Saturday, July 16, 2016

How to Read all the fields from sitecore item programmatically

You are worried because you have added all the fields in the template and it’s coming in the item correctly but it’s not coming in the field collection with the below code implementation:

foreach (Field field in Item.Fields)
  //field value

Also when you call the item field explicit using below code, its coming correctly, then why it’s not coming in the field collection. Yes you are right everything is right except your field value is blank or still set as the standard value only.

string fieldvalue  = Sitecore.Context.Item["fieldName"];

Yes if the sitecore item field value is blank or set as standard value then it’s not fully instantiated in the field collection by default. So what is the solution??

No worries just one line code will resolve your problem; yes put this below line of code before calling the field collection code as below:

Item item = Sitecore.Context.Item;
foreach (Field field in Item.Fields)
  //field value

Yuppy..Now all field is coming in the field collection(including the blank value field)

Hope this article will help you.

Happy sitecoring…

Configure Sitecore 9.1 Content Tagging feature with Open Calais

What is Tagging? Tagging refers to the metadata of the content which is assigned to a content by the content creator and the r...