Items as resources by Sitecore part 5: Gutter

When working as a Sitecore developer with items as resources (IAR items), it would be helpful to have a functionality that allows you to identify which items are IAR items and determine if they have been overwritten. Additionally, it would be great to see the changes made to an overwritten IAR item.

In this blog post, we will explore how the Gutter feature in Sitecore can provide this functionality.

Creating an IAR Gutter

With Sitecore PowerShell, you can easily create a Gutter. For detailed instructions on creating a Gutter, a number of articles are recommended. Be sure to check out Sitecore’s PowerShell integration points content editor. To detect if an item is a resource file and if it has been overwritten, check out the Items as resources PowerShell Content Editor Warning. To compare IAR items, read Items as resources by Sitecore part 4: compare, and to understand how to read IAR .dat files, go to Items as resources by Sitecore part 2: reports.

By combining the above resources, you can create an IAR Gutter in Sitecore PowerShell.

Sitecore Items As Resources gutter

The challenge

The Gutter feature is straightforward, but it also allows you to perform additional actions on click. Nice to have if you click on an overwritten item and want to perform a comparison. The code for the comparison is explained in "Items as resources by Sitecore part 4: compare". However, to execute the code, you need to know which resource file the item is stored in. Accessing the resource file data loaded in the Sitecore Kernel is not possible, or at least I don’t know how to do it. Ideally, Sitecore should provide a public comparison method for more efficient operations. As a workaround, you can find the resource file for an item by opening each resource file one at a time until you find the item. Surprisingly, this process is fast and only needs to be performed when you click to perform a comparison. Bonus feature, this displays the resource file location when clicking on a non-overwritten item.

You can find all the PowerShell code on GitHub.

Sitecore Items as Resources Gutter compare

Installation

After creating the IAR Gutter PowerShell items (by installing the "items.master.iaroverwrittenreport.dat" or pushing the serialized item to Sitecore), follow these steps to activate the Gutter:

  1. In the Sitecore Shell, click the "start" button in de bottom left corner.
    Click "Rebuild the script" integration points.
    Open the PowerShell Toolbox.
  2. Enable the IAR gutter in the Sitecore Content Editor by right-clicking on the left side of the Tree and selecting "IAR Gutter".

You are now able to use the Gutter. All the PowerShell code related to the Gutter and more, can be found on my GitHub.