Exemplo n.º 1
0
        /// <summary>
        /// Renders the content.
        /// </summary>
        /// <param name="printContext">The print context.</param>
        /// <param name="output">The output.</param>
        protected override void RenderContent(PrintContext printContext, XElement output)
        {
            if (this.RenderingItem["Skip"].Equals("1") || !this.Repeatable || SitecoreHelper.HasScriptReference(this.RenderingItem))
            {
                base.RenderContent(printContext, output);
                return;
            }

            if (!string.IsNullOrEmpty(this.QueryFieldName))
            {
                var pages          = this.RenderingItem.Parent;
                var searchCriteria = pages.Axes.GetDescendant("Search Criteria");

                var searchQuery = searchCriteria[HttpUtility.UrlDecode(this.QueryFieldName)];
                if (!string.IsNullOrEmpty(searchQuery))
                {
                    using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
                    {
                        var items = LinqHelper.CreateQuery <SitecoreUISearchResultItem>(context, SearchStringModel.ParseDatasourceString(searchQuery)).Select(toItem => toItem.GetItem());
                        foreach (var item in items)
                        {
                            this.DataSource = item.ID.ToString();
                            if (!string.IsNullOrEmpty(this.ChildDataKeyName))
                            {
                                printContext.Settings.Parameters[this.ChildDataKeyName] = item.ID.ToString();
                            }

                            this.RenderPage(printContext, output, true);
                        }

                        return;
                    }
                }
            }

            this.RenderPage(printContext, output);
        }