• Twitter
  • LinkedIn

Sitecore Site Settings

As long as I have been a developer creating dynamic based websites, I have used some form of storage to contain the more general settings of a site. Developing in Sitecore is no exception, and its ability to expand to multiple site solutions as well as various languages demands it. Within Sitecore you will want to create a Site Settings item that lives in the data section of your site. A specific name is not required, however just naming it "Site Settings" is generally good enough. The fields should specifically be global elements of the site. Also consider globalization and identify fields that may need to be shared to cut down on future maintenance. Here is a list of possible fields to live in you Site Settings item:

  1. Site logo / header image.
  2. Navigation. If your navigation structure is a separate data structure from the content tree then this can be a path to your navigation parent item. If your navigation is content tree based, you could set up excludes here to remove specific items or templates from your navigation.
  3. Defaults. The most common fields to fall under this area would be browser titles and meta data. This will allow all pages to at least show the defaults if author does not fill out the information on a specific page.
  4. Footer text.

Once you have your Site Settings item in place you will need to be able to reference it. For this you should create a reference to it in the configs. Specifically assign the Site Settings item guid to the site tag. This approach will allow one Site Settings item per defined site. Below is a common site definition patch including our Site Settings reference:


  
    
      
    
  

Our Site Settings item is reference with the value of siteSettingsItemID. Finally for easy access, place the call to your Site Settings item in a class:

public static Item GetSettingsItem()
        {
            string itemID = Context.Site.SiteInfo.Properties["siteSettingsItemID"];
            if (!String.IsNullOrEmpty(itemID))
            {
                Item settingsItem = Sitecore.Context.Database.GetItem(ID.Parse(itemID));
                if (settingsItem != null)
                {
                    return settingsItem;
                }
            }

			return null;
        }

Related Blogs

Latest Blogs