All my Sitecore items are called __Standard Values – The fix

In the previous post i described how a tiny error in Sitecore made you believe that all of the Sitecore items are called __Standard Values.

The error occurs in the Danish language because Sitecore unintentionally added the word “__Standard Values” to the Display Name of several items.

A friend of mine asked for a fix. Here it is. You should:

  • Create a new .aspx page in the /sitecore modules/shell folder
  • Ensure that the website is running in the Danish (da) language
  • Copy the following contents to the .aspx page you created.
  • Call the page.

The code iterates through all Sitecore templates, identifies the __Standard Values templates where the display name is “__Standard Values” and deletes the contents in the Display Name field.

<%@ Page language="c#" EnableEventValidation="false" AutoEventWireup="true" %>

<script runat="server">
  
  void Page_Load(object sender, System.EventArgs e) 
  {
    Response.Buffer = false;
    Response.BufferOutput = false;
    Response.Write(string.Format("{0} {1}<br/>", Sitecore.Context.ContentDatabase.Name, Sitecore.Context.Language));
    Sitecore.Data.Items.Item templateRoot = Sitecore.Context.ContentDatabase.GetItem("/sitecore/templates");
    Iterate(templateRoot);
  }

  void Iterate(Sitecore.Data.Items.Item root)
  {
    foreach (Sitecore.Data.Items.Item child in root.GetChildren())
    {
      if (child.Name == "__Standard Values" && child["__display name"] == "__Standard Values")
      {
        Response.Write(string.Format("path: {0}. Name: {1}. Display Name: {2}<br/>", child.Paths.FullPath, child.Name, child["__display name"]));
        FixDisplayName(child);
      }
      if (child.HasChildren)
        Iterate(child);
    }
  }

  void FixDisplayName(Sitecore.Data.Items.Item item)
  {
    item.Editing.BeginEdit();
    item.Fields["__display name"].Value = string.Empty;
    item.Editing.EndEdit();
  }

</script>  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
  <head>
    <title>www.sitecore.net</title>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <link href="/default.css" rel="stylesheet">
  </head>
  <body>
    <form runat="server">
    </form>
  </body>
</html>

As always, use at own risk, take a backup before running etc.

Advertisements

About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, General .NET, Sitecore 7, Sitecore 8 and tagged , . Bookmark the permalink.

One Response to All my Sitecore items are called __Standard Values – The fix

  1. Pingback: All my Sitecore items are called __Standard Values | Brian Pedersen's Sitecore and .NET Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s