/// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> public void Process(GetRenderingItemArgs args) { Assert.IsNotNull(args, nameof(args)); if (args?.RenderingItem != null) { return; } args.RenderingItem = this.GetRenderingItem(args); }
/// <summary> /// Gets the rendering item. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected override Item GetRenderingItem(GetRenderingItemArgs args) { // Check for a sitecore query datasource var query = args.RenderingContext.Rendering.DataSource; if (query.StartsWith("./", StringComparison.InvariantCulture)) { // Relative to the current context item var contextItem = args.RenderingContext.PageContext.Item; if (contextItem != null) { return(contextItem.Axes.SelectSingleItem(query)); } } else if (!string.IsNullOrEmpty(query)) { // Straight sitecore query return(args.RenderingContext.ContextItem.Database.SelectSingleItem(query)); } return(null); }
/// <summary> /// Gets the rendering item. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected override Item GetRenderingItem(GetRenderingItemArgs args) { return(args.RenderingContext.Rendering.Item); }
/// <summary> /// Gets the rendering item. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected abstract Item GetRenderingItem(GetRenderingItemArgs args);