Language Fallback not working for Sitecore Sidekick

Here’s a quick one, I like to use Sitecore Sidekick to quickly test bits of code.

The other day I couldn’t get language fallback to work for the life of me.

After some sleep and some driving (the best time to think) I worked out that it might be because the Sidekick app runs in a weird context.

A bit of debugging and it turns out that:
SiteContext.Current = null

I was expecting maybe “shell”.

So adding the following around the code made language fallback suddenly work:

using (new SiteContextSwitcher(SiteContext.GetSite("shell")))
{

I’m going to also detail some interesting details of how language fallback operates when performing certain actions via the item API but I’ll put that in a separate post to keep them organised 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s