Multiple TemplateIds not working in Sitecore's Advanced Database Crawler

橙三吉。 提交于 2019-12-11 09:33:25

问题


I have a "Featured" widget to lead visitors to items I want to feature on certain pages. So I'm trying to get Alex Shyba's Advanced Database Crawler for Sitecore to return all the items that refer to the context item. If I put in one template ID, it works fine. But if I pipe delimit the two templates, I never get a result. What am I doing wrong?

var searchParam = new MultiFieldSearchParam()
{
    Database = Sitecore.Context.Database.Name,
    Language = Sitecore.Context.Language.Name,
    TemplateIds = "{E5B41848-3C07-4F17-84A5-C2C29AD43CAE}|{0C2E35D7-C4C9-478B-B4AB-DE8C2A00908B}"
};            
var refinements = new List<MultiFieldSearchParam.Refinement>();
refinements.Add(new MultiFieldSearchParam.Refinement("pages", contextItemGUID));
searchParam.Refinements = refinements;

var runner = new QueryRunner("web");
foreach (var skinnyItem in runner.GetItems(searchParam))
{
    yield return skinnyItem.GetItem();
}

Again, if I make that TemplateIds a single GUID (either one), it works as expected, but just returning, obviously, items of the specified template.


回答1:


As Mark notes, it's a bug in the ADC. Our solution was to refactor the ApplyTemplateFilter method as follows:

protected void ApplyTemplateFilter(CombinedQuery query, string templateIds, QueryOccurance occurance)
{
    ApplyIdFilter(query, BuiltinFields.Template, templateIds, occurance);
}


来源:https://stackoverflow.com/questions/11809520/multiple-templateids-not-working-in-sitecores-advanced-database-crawler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!