Okay I got the following class, but item is always null when I GetIstance(); Visual studio shows:
Field 'PageStyle.item' is never assigned to, and will always have its default value null
How can I resolve this? What am I doing wrong? Is there a better way of doing whats done below?
public class PageStyle { private static PageStyle _Instance = null; // Instantiate variables relating to sitecore item paths. Database webDB; Sitecore.Data.Items.Item item; // constructor private PageStyle() { if (webDB != null) { webDB = Sitecore.Configuration.Factory.GetDatabase("web"); Sitecore.Data.Items.Item item = webDB.Items[StartItem]; } } // Method that gets instance public static PageStyle GetInstance() { if (_Instance == null) _Instance = new PageStyle(); return _Instance; } private void InitializeWebDB() { if (webDB == null) { webDB = Sitecore.Configuration.Factory.GetDatabase("web"); } } private void InitializeStartItem() { if (webDB != null) { item = webDB.Items[StartItem]; } } public string StartItem { get { return _startItem; } set { _startItem = value; } } }