/// <summary>
        /// Preliminary render action invoked before RenderContent <see cref="RenderContent"/>.
        /// </summary>
        /// <summary>
        /// Renders the content.
        /// </summary>
        /// <param name="printContext">The print context.</param>
        /// <param name="output">The output.</param>
        protected override void RenderContent(Sitecore.PrintStudio.PublishingEngine.PrintContext printContext, System.Xml.Linq.XElement output)
        {
            if (!string.IsNullOrEmpty(this.ChildDataKeyName))
            {
                printContext.Settings.Parameters[this.ChildDataKeyName] = this.DataSource;
            }

            if (!string.IsNullOrEmpty(this.RenderingItem["Search Query"]))
            {
                string searches = this.RenderingItem["Search Query"];
                using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
                {
                    var items = LinqHelper.CreateQuery(context, UIFilterHelpers.ParseDatasourceString(searches))
                                .Select(toItem => toItem.GetItem());

                    //This gives us our IQueryable

                    foreach (var item in items)
                    {
                        this.DataSource = item.ID.ToString();
                        if (!string.IsNullOrEmpty(this.ChildDataKeyName))
                        {
                            printContext.Settings.Parameters[this.ChildDataKeyName] = item.ID.ToString();
                        }
                        Logger.LogMessage("Found item: " + item.Name);
                        RenderChildren(printContext, output);
                    }
                }
            }
        }
Beispiel #2
0
        protected virtual IQueryable <SitecoreUISearchResultItem> CreateQuery(IProviderSearchContext context, string query)
        {
            var parsedQuery = UIFilterHelpers.ParseDatasourceString(query);
            var linqQuery   = LinqHelper.CreateQuery(context, parsedQuery);

            return(FilterQuery(linqQuery));
        }
Beispiel #3
0
        /// <summary>
        ///     The get data.
        /// </summary>
        /// <returns>
        ///     The <see cref="List" />.
        /// </returns>
        protected virtual List <SitecoreUISearchResultItem> GetData()
        {
            var          indexable = new SitecoreIndexableItem(Sitecore.Context.Item);
            ISearchIndex index     = ContentSearchManager.GetIndex(indexable);

            if (index == null)
            {
                return(new List <SitecoreUISearchResultItem>(0));
            }

            string datasource = DataSource;

            if (datasource.IsNullOrEmpty())
            {
                return(new List <SitecoreUISearchResultItem>(0));
            }

            IEnumerable <SearchStringModel> stringModel = UIFilterHelpers.ParseDatasourceString(datasource);

            using (IProviderSearchContext context = index.CreateSearchContext())
            {
                return(LinqHelper.CreateQuery(context, stringModel).OrderBy(i => i.Updated).Take(MaxCount).ToList());
            }
        }