Reason
When opening the Presentation Details dialog for an item (e.g. the Standard Values for a template) a null reference exception is thrown.
[ArgumentNullException: Value cannot be null. Parameter name: value] Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) +105 Sitecore.Web.WebUtil.SafeEncode(String value) +84 Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.RenderRenderings(DeviceDefinition deviceDefinition, Int32 selectedIndex, Int32 index) +1682 Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.Refresh() +622 Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm.OnLoad(EventArgs e) +703
The issue arises when the placeholder XML-attribute (“ph”) is missing from one or more of the elements in the “Renderings”-field.
I honestly can’t say when or why some of the “ph”-attributes went missing, as the solution in question is 2+ years old and started out as Sitecore 6.6 Update-2. All I know is that earlier versions of Sitecore handled the circumstance gracefully.
If you know what causes this issue, please leave a comment 🙂
This article is based on a Sitecore 8 Update-2 (rev. 150223).
Code
To fix the problem, follow these steps:
- Open the “View” tab and check “Standard fields” and “Raw values”.
- Copy the contents of the “Renderings”-field into a text editor, e.g. Visual Studio.
- Search for any “r”-elements which do not contain a “ph”-attribute.
- Add an empty “ph”-attribute to these elements.
- Copy and paste the modified XML back into the “Renderings”-field.
- Save the item.
Example
A video of how to reproduce and solve this issue can be found here.
It’s worth noting that this error can originate due to the missing ph attribute within an item itself OR in the standard values of it’s template.
Thank for this post, Uli! It definitely fixed my issue.
But after I manually added the “ph” attributes to my layout XML and this fixed my issue, now, if I remove the “ph” attributes, I can’t reproduce the issue anymore! 🙂 Once I put in the “ph” attributes, I can remove them and I no longer get the issue. In other words, I can put the XML back to exactly what it was when I was getting the error you mentioned and I don’t get the error anymore!
Any idea why?
I’m inclined to open a ticket with Sitecore Support because this issue is still happening with the latest version of Sitecore 8.1, rev. 160302.
Hi Douglas,
I’d say opening a ticket is the right thing to do, especially considering the amount of people hitting this issue – I can see that it’s quite a few simply by looking at the visit count on this very blog post!
I’m out of the loop reg. Sitecore and can’t really help with any further insight – I’ve switched jobs and am no longer working with Sitecore CMS.
Thank you sir!
Still helpful years later 🙂