Custom name for rendering in presentation details

5/21/2018 sitecore-modals sitecore-client sitecore-device-editor

This is how to create a custom name for the rendering in presentation details.

Modify the  code behind file of xml file in 

Website\sitecore\shell\Applications\Layouts\DeviceEditor\DeviceEditor.xml

from

<CodeBeside Type="Sitecore.Shell.Applications.Layouts.DeviceEditor.DeviceEditorForm,Sitecore.Client"/>

to

<CodeBeside Type="sitecoreblog.tools4geeks.Applications.Layouts.DeviceEditor.DeviceEditorForm,sitecoreblog.tools4geeks"/>

 

Duplicate original class with your new class name DeviceEditorForm with above namespace. replace RenderRenderings method with below code

private void RenderRenderings(DeviceDefinition deviceDefinition, int selectedIndex, int index)
    {
      Assert.ArgumentNotNull((object) deviceDefinition, "deviceDefinition");
      ArrayList renderings = deviceDefinition.Renderings;
      if (renderings == null)
        return;
      foreach (RenderingDefinition rendering in renderings)
      {
        if (rendering.ItemID != null)
        {
          Item obj = Client.ContentDatabase.GetItem(rendering.ItemID);
          XmlControl webControl = Resource.GetWebControl("DeviceRendering") as XmlControl;
          Assert.IsNotNull((object) webControl, typeof (XmlControl));
          HtmlGenericControl htmlGenericControl1 = new HtmlGenericControl("div");
          htmlGenericControl1.Style.Add("padding", "0");
          htmlGenericControl1.Style.Add("margin", "0");
          htmlGenericControl1.Style.Add("border", "0");
          htmlGenericControl1.Style.Add("position", "relative");
          htmlGenericControl1.Controls.Add((System.Web.UI.Control) webControl);
          string uniqueId = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("R");
          this.Renderings.Controls.Add((System.Web.UI.Control) htmlGenericControl1);
          htmlGenericControl1.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("C");
          webControl["Click"] = (object) ("OnRenderingClick(\"" + (object) index + "\")");
          webControl["DblClick"] = (object) "device:edit";
          if (index == selectedIndex)
            webControl["Background"] = (object) "#D0EBF6";
          this.Controls.Add((object) uniqueId);
          if (obj != null)
          {
            webControl["ID"] = (object) uniqueId;
            webControl["Icon"] = (object) obj.Appearance.Icon;
            webControl["Header"] = (object) obj.DisplayName + "-" + (object) rendering.Datasource ;
            webControl["Placeholder"] = (object) WebUtil.SafeEncode(rendering.Placeholder);
          }
          else
          {
            webControl["ID"] = (object) uniqueId;
            webControl["Icon"] = (object) "Applications/24x24/forbidden.png";
            webControl["Header"] = (object) "Unknown rendering";
            webControl["Placeholder"] = (object) string.Empty;
          } 
          if (rendering.Rules != null && !rendering.Rules.IsEmpty)
          {
            int num = rendering.Rules.Elements((XName) "rule").Count<XElement>();
            if (num > 1)
            {
              HtmlGenericControl htmlGenericControl2 = new HtmlGenericControl("span");
              if (num > 9)
                htmlGenericControl2.Attributes["class"] = "scConditionContainer scLongConditionContainer";
              else
                htmlGenericControl2.Attributes["class"] = "scConditionContainer";
              htmlGenericControl2.InnerText = num.ToString();
              htmlGenericControl1.Controls.Add((System.Web.UI.Control) htmlGenericControl2);
            }
          }
          RenderDeviceEditorRenderingPipeline.Run(rendering, webControl, (System.Web.UI.Control) htmlGenericControl1);
          ++index;
        }
      }
    }

 

This should display rendering name as rendering name - Datasource