コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #4
0
 /// <summary>
 /// Gets the rendering item.
 /// </summary>
 /// <param name="args">The arguments.</param>
 /// <returns></returns>
 protected abstract Item GetRenderingItem(GetRenderingItemArgs args);