public void Process(GetLookupSourceItemsArgs args) { if (!args.Item.InheritsFrom(SitecoreIDs.StandardRenderingParametersTemplateId)) { return; } var url = WebUtil.GetQueryString(); if (string.IsNullOrWhiteSpace(url)) { return; } try { var parameters = FieldEditorOptions.Parse(new UrlString(url)).Parameters; var currentItemUri = parameters["contentitem"]; if (string.IsNullOrEmpty(currentItemUri)) { return; } var contentItemUri = new ItemUri(currentItemUri); var contextItem = Database.GetItem(contentItemUri); args.Item = contextItem; } catch (Exception ex) { Sitecore.Diagnostics.Log.Error(ex.Message, ex, this); } }
public Item[] ListQuery(Item item) { bool flag = !string.IsNullOrWhiteSpace(Context.RawUrl) && Context.RawUrl.Contains("hdl"); if (flag) { string renderingId = FieldEditorOptions.Parse(new UrlString(Context.RawUrl)).Parameters["rendering"]; if (!string.IsNullOrEmpty(renderingId)) { ItemUri renderingItemUri = new ItemUri(renderingId); var containers = DependencyResolver.Current.GetService <IPresentationRepository>().GetStylesItem(renderingItemUri.ItemID, item); if (containers == null) { return(new Item[0]); } return(containers.Children.ToArray <Item>()); } } var result = new Item[0]; return(result); }
public void Process(GetLookupSourceItemsArgs args) { if (!args.Source.Contains(scapePrefix)) { return; } Item contextItem; // Only goes ahead if this is a Parameters Template if (args.Item.Template.BaseTemplates.Where(bt => bt.ID == BaseParameterTemplate).Any()) { // This whole block is to get Context Item string url = WebUtil.GetQueryString(); if (string.IsNullOrWhiteSpace(url)) { args.Source = String.Empty; return; } FieldEditorParameters parameters = null; try { parameters = FieldEditorOptions.Parse(new UrlString(url)).Parameters; } catch (Exception) { } if (parameters == null) { args.Source = String.Empty; return; } var currentItemId = parameters["contentitem"]; if (string.IsNullOrEmpty(currentItemId)) { args.Source = String.Empty; return; } ItemUri contentItemUri = new ItemUri(currentItemId); contextItem = Database.GetItem(contentItemUri); } else { contextItem = args.Item; } // Now to the custom (site-specific) parameters var sourceName = args.Source.Replace(scapePrefix, "").Trim(); args.Source = provider.GetSource(contextItem, sourceName); }
public void Process(GetLookupSourceItemsArgs args) { //should we care? if (HasLookup(args.Source)) { var url = WebUtil.GetQueryString(); if (string.IsNullOrWhiteSpace(url)) { return; } var fieldEditorOptions = FieldEditorOptions.Parse(new UrlString(url)); var parameters = fieldEditorOptions.Parameters; var currentItemId = parameters[Constants.FieldEditor.RenderingParameters.ContentItem]; if (string.IsNullOrEmpty(currentItemId)) { return; } // get the context item. var contentItemUri = new ItemUri(currentItemId); var contextItem = Database.GetItem(contentItemUri); // get all item fields, filter out standard fields and order. maybe group by section in future? contextItem.Fields.ReadAll(); var itemFields = contextItem.Fields.Where(f => !f.Name.StartsWith("__")).OrderBy(f => f.DisplayName); foreach (Field field in itemFields) { // check if we support the field type if (IsSupportedField(field)) { args.Result.Add(field.InnerItem); } } // if no other queries to be served, no need to continue pipeline args.AbortPipeline(); } }