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.
By combining the above resources, you can create an IAR Gutter in Sitecore PowerShell.
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.
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:
In the Sitecore Shell, click the "start" button in de bottom left corner.
Click "Rebuild the script" integration points.
Open the PowerShell Toolbox.
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.
Want to know more?
Want to read more technical blogs from Sitecore MVP Jan Bluemink? You might find these interesting: