CMS 10.6 Configuring the ICE Helper


For CMS 10.6 ICE, the RenderICEAttribute helper function requires major updates. You may need to update the _Helpers.cshtml file in your DSS Project.

Important
The following updates may only be required for existing implementations. Newly created DSS Preview solutions for CMS 10.6 sites already have these changes in place.

To update your DSS Project _Helpers.cshtml file:

  1. Navigate to [Drive]:[path-to-DSS-root-folder]\App_Code.
  2. Open _Helpers.cshtml in a text editor, and locate @helper RenderICEAttribute(ICMSElement ele, bool isComponent = false) in the code.
  3. Delete the code nested within @helper RenderICEAttribute(ICMSElement ele, bool isComponent = false) and paste the following code.
    Caution
    Ensure you replace all @helper RenderICEAttribute(ICMSElement ele, bool isComponent = false) code with the following code. If you incorrectly paste the code, errors will occur.
    @helper RenderICEAttribute(ICMSElement ele, bool isComponent = false)
    {
    	if (ele != null && ele.EditMode)
    	{
    		var uid = ele.Content.GetAttributeValue("UID", string.Empty);
    
    		//skip any field without uid, since they can be unembedded component content and don't deserve
    		//to be ice field itself
    		if (!string.IsNullOrWhiteSpace(uid))
    		{
    			var page = ele.Page;
    
    			string fieldName = ele.Content.Name.LocalName;
    			if ((fieldName == "Page" || isComponent) && ele.Attribute("Name") != null)
    			{
    				fieldName = ele.Content.GetAttributeValue("Name", "");
    			}
    
    			__razor_helper_writer.Write("EditFieldName=\"" + fieldName + "\" ");
    
    			if (ele.GetAttributeValue("Type") == "Component")
    			{
    				string compRootName = "";
    
    				if (ele.GetAttributeValue("WrappedUp") != "true")
    				{
    					compRootName = ele.Content.Name.LocalName;
    				}
    				else
    				{
    					var compContent = ele.Content.Elements().FirstOrDefault();
    					compRootName = compContent == null ?
    						"" :
    						compContent.Name.LocalName;
    				}
    
    				if (!string.IsNullOrEmpty(compRootName))
    				{
    					__razor_helper_writer.Write("_ComponentType_=\"" + compRootName + "\" ");
    				}
    			}
    
    			__razor_helper_writer.Write("EditFieldId=\"" + uid + "\" ");
    
    			var ancestorIds = ele.GetAttributeValue("ICEUpdate_FullID")
    				.ToNullOrEmptyHelper()
    				.Return(Request.Form["elementId"]
    					.ToNullOrEmptyHelper()
    					.Return(ele.GetAttributeValue("EditFieldFullID")));
    
    			//backward compatibility, for older version than 10.6, where EditFieldFullID doesn't exist
    			if (string.IsNullOrEmpty(ancestorIds))
    			{
    				var rawEle = (page as CMSPageRequest).RawContent
    					.Descendants()
    					.FirstOrDefault(e => e.Name == ele.Content.Name
    						&& e.GetAttributeValue("UID", "") == uid);
    
    				if (rawEle == null)
    				{
    					rawEle = ele.Content;
    				}
    
    				ancestorIds = rawEle.AncestorsAndSelf()
    				   .Select(
    					   aEle =>
    					   {
    						   string fullId = aEle.GetAttributeValue("ICEUpdate_FullID", "");
    
    						   if (string.IsNullOrEmpty(fullId))
    							   fullId = aEle.GetAttributeValue("UID", string.Empty);
    
    						   return fullId;
    					   })
    				   .Where(
    					   id => !string.IsNullOrWhiteSpace(id))
    				   .Reverse()
    				   .JoinString("|");
    			}
    
    			__razor_helper_writer.Write("EditFieldFullId=\"" + ancestorIds + "\" ");
    
    			if (ele.GetAttributeValue("Embedded") == "true")
    			{
    				__razor_helper_writer.Write("EditField_Embedded=\"true\" ");
    			}
    
    			if (ele.GetAttributeValue("WrappedUp") == "true")
    			{
    				__razor_helper_writer.Write("EditField_WrappedUp=\"true\" ");
    			}
    
    			string compTypes = ele.GetAttributeValue("CompTypes");
    
    			if (!string.IsNullOrEmpty(compTypes))
    			{
    				__razor_helper_writer.Write("EditField_CompTypes=\"" + compTypes + "\" ");
    			}
    
    			if (!string.IsNullOrEmpty(ele.ViewMode))
    			{
    				__razor_helper_writer.Write("EditFieldTemplateMode=\"" + ele.ViewMode + "\" ");
    			}
    		}
    	}
    }
  4. Save and close _Helpers.cshtml.

Next Steps: Configure the controller for CMS 10.6 ICE setup.