Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Gets the rendering item.
 /// </summary>
 /// <param name="args">The arguments.</param>
 /// <returns></returns>
 protected abstract Item GetRenderingItem(GetRenderingItemArgs args);