public override Sitecore.Data.FieldList GetItemFields(Sitecore.Data.ItemDefinition itemDefinition, Sitecore.Data.VersionUri versionUri, CallContext context) { var fields = context.CurrentResult as FieldList; if (fields == null || fields[Sitecore.FieldIDs.Source].IsNullOrEmpty() || !fields[Sitecore.FieldIDs.Style].IsNullOrEmpty()) { return(null); } var newFields = new FieldList(); newFields.Add(Sitecore.FieldIDs.Style, Style); return(newFields); }
/// <summary> /// Loads a set item definitions into the cache by using the parameters array passed as parameter. Parameters are in the form of {"ItemId", "{Sitecore Id}"} /// </summary> /// <param name="parameters"></param> /// <param name="prefetchData"></param> protected virtual void LoadItemDefinitions(object[] parameters, SafeDictionary <ID, PrefetchData> prefetchData) { #region VARIABLES ItemDefinition oItemDefinition; string sItemId; int iParameterIndex; List <string> oItemIds; List <ItemDefinitionContract> oItemDefinitions; PrefetchData oData; //Add variables here... #endregion if (parameters != null && parameters.Length > 1) { oItemIds = new List <string>(); for (iParameterIndex = 0; iParameterIndex < parameters.Length; iParameterIndex += 2) { if (ID.IsID(parameters[iParameterIndex + 1].ToString())) { sItemId = parameters[iParameterIndex + 1].ToString(); oItemIds.Add(sItemId); } } if (oItemIds.Count > 0) { using (var oContentService = new GenContentServiceProxy()) { oItemDefinitions = oContentService.GetItemDefinitions(oItemIds, this.CurrentDatabase); } if (oItemDefinitions != null && oItemDefinitions.Count > 0) { try { foreach (ItemDefinitionContract oItemDefinitionContract in oItemDefinitions) { oItemDefinition = new Sitecore.Data.ItemDefinition( new Sitecore.Data.ID(oItemDefinitionContract.Id), !string.IsNullOrEmpty(oItemDefinitionContract.Name) ? oItemDefinitionContract.Name : string.Empty, !string.IsNullOrEmpty(oItemDefinitionContract.TemplateId) ? new Sitecore.Data.ID(oItemDefinitionContract.TemplateId) : null, !string.IsNullOrEmpty(oItemDefinitionContract.BranchId) ? new Sitecore.Data.ID(oItemDefinitionContract.BranchId) : null ); oData = new PrefetchData(oItemDefinition, !string.IsNullOrEmpty(oItemDefinitionContract.ParentId) ? new Sitecore.Data.ID(oItemDefinitionContract.ParentId) : ID.Null); prefetchData[oItemDefinition.ID] = oData; Sitecore.Diagnostics.Log.Debug(string.Format("GetItemDefinition, Item Cached:{0}", oItemDefinition.ID.ToString()), this); } } catch { Sitecore.Diagnostics.Log.Error("GetItemDefinition, Unable to get item definitions", this); throw; } } } } }