Experience Sitecore ! | More than 200 articles about the best DXP by Martin Miles

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

Sitecore 8.1 has been released!

As we have been waiting for it, Sitecore 8.1 is now released. That is a feature version, and it has such a massive what's-new and improvements list, that it may take you just 20 minutes to read it through!

Everything can be downloaded from official SDN website, as usual. If you are using Sitecore Instance Manager, please update it to latest version to support latest build (and rename it according to SIM naming convention -Sitecore 8.1 rev. 151003.zip. If not - it is now a good time to consider that handy software (read my article about it).

Also Sitecore xDB Cloud should get out of beta along with 8.1 release - there is now xDB Cloud Usage Policy available there.

So, briefly, what are new / fixed features?

  • SPEAK updated to 2.0 - now there's less SPEAK plumbing to go with it, more time to concentrate on business logic (link)
  • Sitecore 8 may now function as normal with xDB disabled - this is called CMS-only mode (link)
  • MVC Areas now work out-of-the-box (link)
  • Experience Editor improvements (both functional and performance)
  • Multiple xDB and Analytics improvements, new Path Analyzer
  • Contact Behavior Profile - enabled "dynamic" personalization based on previous contact activity (sort of artificial intellect)
  • Language Fallback now works out-of-the-box
  • xDB now fully support Mongo 3.0
  • Analytics got more missing UI
  • Sitecore subscription-based services
  • Device Detection (as subscription-based service) now identifies device types out of box bases on hundreds of params
  • Geo IP now is a subscription-based service
  • Sitecore now logs client-side javascript errors along with its own backend exceptions
  • CMS-only mode (link)
  • Shared / versioned layouts improvements
  • All associated modules updated as well (WFFM, ECM, etc.)

Breaking licensing change: Sitecore 8.1 now requires a license with the “Sitecore.xDB” key to enable all features of the Experience Platform. If your license file does not contain this key, Sitecore will default to Experience Management (CMS-only) mode. Any customers or partners with a license to Experience Platform should contact their account manager or login to SPN if they are missing this key.

Read more by official Release Notes link

StackOverflow: Can a multilingual Sitecore 6 web page have an alias for each language?

Question on StackOverflow - can a multilingual Sitecore 6 web page have an alias for each language? (link to original question)

Can a multilingual Sitecore 6 content page have an alias for each language? It appears that I can only add one per content page. For instance, labour_market_survey.html has an english page and a french page:


But I can only give the content page one alias: http://www.site.ca/survey
How can I add a french alias, such as: http://www.site.ca/enquete ?
Answer: aliases are just sort of web-root-level "links" to certain items, mostly intended to use for marketing campaigns as short and friendly Tokens. To achieve what you want you may consider few options:
  1. If you have configured an individual website for each language - then you may create SiteAliasResolver processor for HttpBeginRequest pipeline. This will give you an option to have aliases on website level. Please reed this blog post describing how to achieve that (with code samples).

  2. Another option would be to use Redirect Module, as it will do exactly what you need. There was a question on Redirect Module recently, so there is exact example how to create a redirect item for any virtual URL that will do 301 to any specific sitecore item (which belong to some page item under corresponding language website): enter image description here

  3. If you are resolving languages on-a-fly so that the same item in Sitecore serves different languages (based on criteria how you resolve that), then you may use aliases as they are (but as I understood from your example that isn't your case)

P.S. Also, if you decide to go with aliases, mind Canonical URLs (link one and link two) as they may affect your SEO.

Hope someone finds that helpful!

Sitecore Improvements project

I have done multiple Sitecore presentation and productivity improvements, so this time I decided to unite them all under the same umbrella in GitHub, and this blog post will go through all of them.

1. Sitecore Style Adjustments

2. Device Editors Shortcuts

3. Layout Details Shortcuts

4. Presentation Exists Gutter

5. Publish Item Context Menu

6. Publish Item Ribbon Icon

7. Set Presentation Context Menu Icon

Packages can be downloaded below:

Sitecore 8.0 Style Adjustments-1.2.zip (29KB)
Sitecore 8.1 Style Adjustments-1.2.zip (28.9KB)
Device Editor Shortcuts 1.0.zip (8.6KB)
Layout Details Shortcuts 1.1.zip (10.8KB)
Presentation Exists Gutter 1.0.zip (12.7KB)
Publish Item Context Menu-1.0.zip (11.1KB)
Publish Item Ribbon Icon 1.0.zip (4.2KB)
Set Presentation Context Menu Item 1.0.zip (11.4KB)

Source code (and the docs / more packages) can be taken from project's GitHub page by the following link.

Hope you find this helpful!

StackOverflow: How to use Redirect Module in Sitecore

One guy recently posted a question on StackOverflow on how to use Redirect Module. So I decided to reply about that, but thought it is a good topic for a blog post.

First of all, he probably meant a Sitecore Redirect Module from Marketplace. I have heard multiple complaints on that one and that it doesn't work as expected, moreover it seems to be discontinued.

Luckily, there are many forks of that one on the internet, as ability to control 301 redirects right from Sitecore is well in demand. I want to suggest probably the best fork I found and am successfully using myself - done by Chris dams and Max Slabyak. Why?

  • module is developing with time - just recently there was new version 1.4 that introduced ability to specify various status codes
  • good documentation included
  • sourcecode is available on Github under MIT license - feel free to use imn your commercial projects
How to get it: all you need including sources, packages for all versions and documentation is available from GitHub by this link.

Let's now create a sample redirect from a virtual URL of non-existing page to some page item in Sitecore.

We want everyone who tries accessing http://our.sample.website/pagename (note that there is no pagename item in Sitecore) to be redirected to another existing page that sits at /sitecore/content/Home/landingPage in Sitecore. For the first time, for sure, as 301 redirects are cached in user's browser and next time he/she would be taken directly to landing page (by browser).

  1. Under /sitecore/system/Modules/Redirect Module folder in Sitecore create a new redirect pattern called Pagename Test
  2. Set requested expression to ^/pagename/?
  3. Leave response status code equal 301
  4. Set source item to the actual page item serving that redirect request
  5. Do not forget to publish redirect pattern (and module itself if not yet)

A screenshot below shows how it looks in Sitecore:

Hope you find that useful!

Sitecore Personalization based on URL query string parameters

Once I was asked to personalize Sitecore component depending on custom URL query string parameter, to identify users coming by a promo campaign in order to display them slightly modified component reflecting campaign presentation. Easy, I thought, but in next couple minutes struggled to find that condition in Rules Engine. It is not in Sitecore, what a surprise!..

So, let's go through and see what conditions are in Sitecore and how you can create any custom condition you would ever imagine.

First of all, all stuff for Rules Engine is specified as Sitecore items underneath /sitecore/system/Settings/Rules folder. So let's create an item named Query String Value Presents of /sitecore/templates/System/Rules/Condition template within /sitecore/system/Settings/Rules/Conditional Renderings/Conditions/URL Query String Conditions folder. There are just two important fields we are going to set. Type field, as it is very common to Sitecore, specifies fully qualified class and assembly names, where business logic is implemented. Another, Text field, is more interesting on that stage - it shows wordings that would be presented to user when using his condition with Rules Engine. Here is what we set there:

Where the User [QueryStringName,,,QueryString Name] has a value that [operatorid,StringOperator,,compares to] [QueryStringValue,,,QueryString Value].

Pay attention to parameters in square brackets - they would be replaced by Rules Enging to selectors.

Now let's look at the code. Fom the item we ahave referenced the class.

public class QueryStringCondition<T> : StringOperatorCondition<T> where T : RuleContext

All derived condition classes should have same definition and derive from base StringOperatorCondition class. As the absolute minimal, we are to override just one Execute(T ruleContext) method. Additionally we must create public string properties named exactly the same as in parameters above from Text field from condition definition item in Sitecore.

public string QueryStringName { get; set; }
public string QueryStringValue { get; set; }
protected override bool Execute(T ruleContext)
    // process QueryStringName and QueryStringValue properties here
    // return true if personlization parameters falls within the condition 

QueryStringName and QueryStringValue would be auto-populated by Rules Engine.

With our next example we are trying to display an additional promo component when user access our website by URL with sourceId=campaign as parameters.

Full implementation of QueryStringCondition<T> class can be found on GitHub by this link.

Hope you find this helpful!

Productivity Improvement: Device Editor showing datasource and previewing that right from a pop-up click

After previous post on Layout Details dialog improvements, I decided to look even further and implement one more improvement that came into my head.

Another dialog window, probably most important in Content Editor is missing couple things I just decided to fix. That is a case when a screenshot is better than hundred words, so here is it:

What has been added is a datasource item path, immediately underneath rendering and placeholder. It is clickable in the same manner as from previous posts, immediately opening that (datasource) item for view and edit right in the popup window, that saves so much time!

Additionally, rendering / sublayout name became also clickable with the same item preview popup effect.

Download: please get the package and anti-package to revert changes. Source code is available at GitHub page by this link.

Known minor issue: if open Control Properties dialog from Device Editor, and when you return back from that dialog - look-up links will not work and control will return to default behavior, so you may need to re-open Device Editor again.
The reason for such a behavior is that on returning back, Sitecore runs a series of pipelines that eventually call original class from Sitecore.Client rather than the one we have overridden and referenced above. Fixing that requires patching original DLL and I highly wanted to avoid inclining into any original functionality (moreover, you are not likely allowed to do that by license)

StackOverflow 2 questions on Multi-Site configuration: Multisite Best Practice for setting up Visual Studio Project and Manage web.config in multisite solution

Got to answer two question about multi-site configuration working with Sitecore:

1. Sitecore Multisite Best Practice for setting up Visual Studio Project (link to original question)

I'm seeking an advise on best practice that has worked for creating a asp.net MVC visual studio solution that supports multisite (multi tenant). One thing we would like to do is minimize the regression defects so that developer don't modify the wrong website code base etc.
That the solution needs to support more than 8 web sites.

2. Manage web.config in sitecore multisite solution (link to original question)

We have a multisite solution with individual visual studio solutions for each websites. Then we have master solution to build/deploy all websites.
Firstly, not sure whether it's a best practice to include web.config in Visual Studio solution. But I think all the nuget packages needs web.config to add their settings.
As a result, we have web.config for each solution. However when we deploy from master web.config gets overwritten by each sites. Could someone please suggest how this issue can be fixed?


I have got one more alternative to address that. Currently working on a huge project, with dozens of developers and quite bureaucratic process of deployments, we have introduced the following approach:

  1. Project consists of multiple logical subparts, which in fact are individual websites.
  2. Each of those websites we set up as an MVC Area with own controllers, views etc
  3. Most important - we set up MVC Areas as individually pluggable DLLs. So each of that websites is a separate project under solution, with its own resources and statics; on build everything is copied under their required paths and DLL goes to the \bin folder.
  4. One more class library for shared (by all websites) resources, it is being referenced only by those sites, that need that functionality
  5. In Sitecore, we have the same strict principles - the content, layouts, renderings are isolated as higher as possible, no individual content may be re-used (unless from shared resources folder).

This approach serves us almost a year already and has proven for its agility, much easier deployment and fairly less code merge conflicts. If you are working under just one site - you don't need to re-compile and re-deploy everything - just replace one dll at bin folder.

Thus, combining that with your question, Approach 1 would be an answer.

References (more to read):

Regarding managing configuration, I would advise for each website (under its individual project) to create it's own App_Config/Include folder and create _project_name_.config within that folder in order to keep all site-specific settings there (for further merge into resulting config).

On build you set up (for each individual project) that file to be copied into main SITECORE_INSTANCE_WEB_ROOT\App_config\Include folder along with the rest of include patch config files.

Hope someone finds that helpful!

Productivity Improvement: Creating a Presentation Exists Gutter - get even faster access to item's Presentation Details

Previously I have described how easily you can create a shortcut to Device Editor of Presentation Details right at the item's Context Menu - access that as much as in two clicks! But there's even easier (and more visual) way - create a specific Sitecore Gutter.
So, what Gutters are? Gutters are sort of visual markers you can optionally enable / disable in your Content Editor. Have you seen a vertical bar, immediately left hand side from Sitecore tree? That is a Gutters Area and once you do right click on it - you may enable / disable some gutters already installed. Also, gutters can be clickable, and on click handler you may also call Sitecore commands, so why not to call our familiar item:setlayoutdetails that opens Device Editor dialog for corresponding item?

So, let's create our own gutter. Every gutter is configured within core database under /sitecore/content/Applications/Content Editor/Gutters folder. We are going to create a new item called ... derived from /sitecore/templates/Sitecore Client/Content editor/Gutter Renderer template (all gutters derive from that one). There are only two fields we need to set there - Header which is just a gutter name and Type - fully qualified class name:

So now let's implement PresentationExists class. Briefly, every gutter derives from GutterRenderer class which returns GutterIconDescriptor object when gutter should be shown next to corresponded item otherwise just null. Implementation below checks whether current item has a Layout associated, and if yes - it returns a GutterIconDescriptor with a item:setlayoutdetails command for that item.
public class PresentationExists : GutterRenderer
    protected override GutterIconDescriptor GetIconDescriptor(Item item)
        if (item != null)
            var layoutField = item.Fields[Sitecore.FieldIDs.LayoutField];
            var layoutDefinition = LayoutDefinition.Parse(LayoutField.GetFieldValue(layoutField));

            if (layoutDefinition != null && layoutDefinition.Devices.Count > 0)
                GutterIconDescriptor gutterIconDescriptor = new GutterIconDescriptor
                    Icon = "Applications/32x32/window_colors.png",
                    Tooltip = Translate.Text("Presentation is set for this item.")

                if (item.Access.CanWrite() && !item.Appearance.ReadOnly)
                    gutterIconDescriptor.Click = string.Format("item:setlayoutdetails(id={0})", item.ID);
                return gutterIconDescriptor;

        return null;
So as soon as you compile and place resulting DLL under <web_root>\bin folder, your gutter wil work like below:

Clicking that icon will immediately show Device Editor dialog. Job's done!

Downloads: you can access source code at Sitecore Improvements project GitHub page, or you can download ready-to-use package by this link.

Please note: improperly implemented gutters may affect performance of Content Editor, as the code above runs for each item. So please be extremely attentive on what you're doing within GetIconDescriptor() method.

StackOverflow: Including MVC in existing Sitecore Project

Recently one chap has asked a question oh how to include MVC into existing Sitecore project. A guy coming from classical ASP.NET MVC background experienced confusion with MVC implemented in Sitecore (here's an original link on StackOverflow). I decided to give a comprehensive answer on how MVC work with Sitecore:

Answer: In the very simplest way, you need to have the following:

  1. Item for your page, the one that has URL; that is as normal in Sitecore
  2. That page Item should have Layout assigned. From Presentation --> Details menu select at least a layout on that stage. If you do not have layout yet, you need to create a layout definition item under /Layout/Layouts folder and associate it with certain *.cshml file. Also mention that layout should have a placeholder where you will "inject"your rendering.

  3. You need to create a Controller Rendering under /Layout/Renderings folder in Sitecore. Make sure you set Controller and Controller Action fields to your controller name and action method name. enter image description here

  4. Finally, go again to Presentation --> Details --> Edit --> Controls and add your newly created rendering into a placeholder that you have on your layout *.cshtml file. enter image description here

That's all done.

Item not published. Why? Let's troubleshoot that!

Have you experienced that at least once? You perform publishing, and refresh the website with strong anticipation of new viewing fresh changes and.... not updated. Why? What's going on? Do not panic, let's carefully troubleshoot that step by step.

1. First, and most frequent reason for item tot being published is a case when item is in a workflow, and current workflow state is not final (ie. draft). For that scenario solution is pretty easy as there's nothing wrong - just follow the workflow until item gets to its final state and would be automatically published (that is configured as default behavior). If workflows are not part of your solution - just remove item's template and standard values out of workflow; as well as individual items manually configured; then re-publish.

2. If previous step dodn't help, find out is the item publishable at all? Check item's Publishing Restrictions. You may check that clicking Change button from Publish ribbon in Sitecore. Please find official documentation by this link, as it may be helpful to understand what Publishing Restrictions are and how they work; also there's another great article by John West about those restrictions. Ensure that your item either doesn't have time limit frames, or falls within them.

Most of publishing issues occur just because of inattentiveness. Are you publishing the right version of item? if that's about child items not being published, haven't you forgotten check Publish Subitems for that (or deep=true if publish from the code)? Are you publishing to the right target? Sure about this? OK for that, but what about that target in ConnectionsString.config, does it match desired database as well? All those questions may seem silly once, but still may hurt and stole fair portion of your time and efforts.

4. Next, do not forget about security and permissions. Here is the wide range of thing to consider! Can logged user perform publish, does he have enough permissions to do that? Check if user is in Sitecore Client Publishing role. Further, does default/anonymous user have access rights for the item (or any of its parents), aren't they removed? Not obvious, but publishing won't work otherwise. If publishing is scheduled and performed by the PublishAgent, does it have rights? Please read one more great article by John West.

5. Running on Publishing Instance (that's just a dedicated clone of CM instance, scaled by design for publishing performance on highly loaded environments)? Ensure it is up and running (lol! but sad truth of life).

6. Sill with us here? It's now time to check EventQueue. Ensure all your instances have the correct time set and synced. Just to remind, Sitecore internally stores everything in UTC format. but timezones should match as well. Check Event Queue settings and ScalabilitySettings.config as well.

7. Any issues with caches? Generally, the rule is: less cache you have, slower publishing is, with a bottom moment where it stops at all. Another silly assumption - aren't you running out of free space on system drive? Also make sure HtmlCacheClearer is added to your publish:end:remote event. It will produce a log record like that:

5760 19:57:16 INFO  HtmlCacheClearer clearing HTML caches for all sites

8. Once I came across the case of a new article not being published. The item looked as normal with no publishing restrictions and outside of workflow. However, it did not appear at the publishing target, as since I was using Sitecore Publishing Service I could only see that "0 versions published".

While investigating around at publishing target, I also noted that parent item was missing. When looking at parent at master database I noticed an information bar saying that parent items had 0 versions. That was the exact reason: parent item was not published due to the lack of versions, and its actual child item did not do through because Sitecore does not allow having orphaned items - a given item did not have a parent at the destination. Creating and publishing a version for the parent item has fixed that problem.

9. The last, quite a rare scenario: some of those curious experimenters like I am, who frequently install dozens of fresh instances of Sitecore for their sandbox trials, usually forget to initially publish entire site on a fresh install, so that it process all the required dependencies. Normally, I would not mention that, but still want to share as many cases as I know.

OK, so many things to consider? Agree with you, that's why I wrote that article, sort of cheat sheet in order to have it at my fingertips. But that's not all. Look for the general troubleshooting plan when something is not been published.

  • as given, item does not present there (on target), but what about its parent item? If missing, what about parent of the parent? Go to master database and carefully inspect the highest unpublished descendant, what isn't correct with it?
  • check workflows, publishing restrictions etc. mentioned above in the beginning of this article.
  • check logs for anything helpful
  • create a copy unpublished item and try to publish that one to the same destination.
  • create another new item of the same template and try to publish it. Succeeded with that?
  • delete and recreate that and related items (layouts, renderings, template) on target, and re-publish
  • handle publish:fail event and try to identify the reason; would be great to step into the method with debugger, if available.
Finally, (remember, I said no panic in the beginning), there is a buletproof solution as the last resort - copy items between databases manually. Go to Control Panel --> Database --> Move an item to another database, where you can move items between databases. One thing to mention - do not forget to update caches after you finish copying items to your target environment.

There are few more things I'd like to mention regarding publishing:

1. I would highly recommend The Published Item Comparer - a Sitecore module that quickly validates the current item in the content tree with the same item in a target database such as the “web” database; this helps to identify publishing issues effectively.

2. Unlike presented, Smart Publishing just cannot be trusted entirely, if reliability is your number one criteria - use re-publish instead.

Hope this post helps and wish your items always to appear on targets!