v4.11.10 Content Package - MNTP Exceptions after import in destination
I have a content package to import content from one install to another between 2 v4 installs. After importing the content package in the target install I am unable to access a lot of the imported nodes due to a null reference exceptions occurring in the MNTP control.
[NullReferenceException: Object reference not set to an instance of an object.]
umbraco.editorControls.MultiNodeTreePicker.MNTP_DataEditor.SelectedValues_ItemDataBound(Object sender, RepeaterItemEventArgs e) +743
An educated guess would tell me this is because the MNTP control is referencing the id's of nodes from the original install which are no longer present or at least not the expected nodes in the new install. Because the nodes won't render this can't be rectified.
Is my only chance here to modify the v4 core so that the control still loads and lets me select new nodes?
OK so further to this I've now resolved the issue but it involved patching the v4.11.10 Core. The error is as I thought caused by some of the saved node id's in the MNTP now relating to nodes which are not actually content nodes in the CMS in the new site.
In MNTP_DataEditors.cs there is the following:
if (loadedNode.ContentTypeIcon.StartsWith(".spr")) lnkSelectNode.Attributes["class"] += " " + loadedNode.ContentTypeIcon.TrimStart('.');
else
{
//it's a real icon, so make it a background image
lnkSelectNode.Style.Add(
HtmlTextWriterStyle.BackgroundImage,
string.Format("url('{0}')", IconPath + loadedNode.ContentTypeIcon));
//set the nospr class since it's not a sprite
lnkSelectNode.Attributes["class"] += " noSpr";
}
Because some of the nodes were not actually content nodes they don't have a ContentTypeProperty and so triggers a null reference exception when the property is access. This can simply be amended to check for the null value first as follows:
if (loadedNode.ContentTypeIcon != null)
{
if (loadedNode.ContentTypeIcon.StartsWith(".spr")) lnkSelectNode.Attributes["class"] += " " + loadedNode.ContentTypeIcon.TrimStart('.');
else
{
//it's a real icon, so make it a background image
lnkSelectNode.Style.Add(
HtmlTextWriterStyle.BackgroundImage,
string.Format("url('{0}')", IconPath + loadedNode.ContentTypeIcon));
//set the nospr class since it's not a sprite
lnkSelectNode.Attributes["class"] += " noSpr";
}
}
The nodes now load and so do the MNTP's but with "Node No Longer Exists" messages in most of the nodes positions.
If someone else is unlucky enough to have the same problem hopefully this helps!
v4.11.10 Content Package - MNTP Exceptions after import in destination
I have a content package to import content from one install to another between 2 v4 installs. After importing the content package in the target install I am unable to access a lot of the imported nodes due to a null reference exceptions occurring in the MNTP control.
An educated guess would tell me this is because the MNTP control is referencing the id's of nodes from the original install which are no longer present or at least not the expected nodes in the new install. Because the nodes won't render this can't be rectified.
Is my only chance here to modify the v4 core so that the control still loads and lets me select new nodes?
Thanks, Simon
OK so further to this I've now resolved the issue but it involved patching the v4.11.10 Core. The error is as I thought caused by some of the saved node id's in the MNTP now relating to nodes which are not actually content nodes in the CMS in the new site.
In MNTP_DataEditors.cs there is the following:
Because some of the nodes were not actually content nodes they don't have a ContentTypeProperty and so triggers a null reference exception when the property is access. This can simply be amended to check for the null value first as follows:
The nodes now load and so do the MNTP's but with "Node No Longer Exists" messages in most of the nodes positions.
If someone else is unlucky enough to have the same problem hopefully this helps!
Simon
is working on a reply...