Core Blimey! - Sitecore Blog

Scope to this in Sitecore?

May 10, 2015 | 1 Minute Read

I was using Visual Studio’s scope to this functionality the other day and had a thought - what if I could do this in Sitecore? What if I could narrow down to a section of the Content Editor tree to where I was working at that time and put aside everything else in the tree. Surely I would be more relaxed and in a zen-like state?

Well, not exactly, but I had fun doing it and learned a bit about the content editor and some core bits of Sitecore.

The solution consists of two context menu items that allow you to scope or descope the Sitecore item you have selected.

context menus

The context menu items fire off two different Sitecore commands


The magic happens in the method SheerResponse.SetLocation.

If you supply this method with a modifed content editor URL then it will set the root node.

Just one querystring parameter needs to be modified in the URL in order to change the root node - the ro parameter.

We can use some of Sitecore’s utility classes to make this really easy.

Then the last piece in the puzzle is how to actually store the scoped item as a setting. This one was new to me but Sitecore has a registry where you can place settings per user.

With this in place you can now start scoping your Sitecore nodes.

Let’s scope to the Layouts node!



So, will this change your life or is this a chocolate teapot?

Let me know your thoughts!

The full code for the solution is available here