C# 具有多个源的Sitecore Droplist
我有一个数据模板,其中有一个DropList字段。我希望数据源来自两个Sitecore文件夹项C# 具有多个源的Sitecore Droplist,c#,asp.net,.net,content-management-system,sitecore,C#,Asp.net,.net,Content Management System,Sitecore,我有一个数据模板,其中有一个DropList字段。我希望数据源来自两个Sitecore文件夹项 是否要为一个droplist定义多个源?不在标准droplist字段中,但基于droplist创建一个自定义sitecore字段应该不会太困难,该字段从源字段中获取两个参数 这是创建自定义控件的良好资源: droplist控件使用Sitecore.Shell.Applications.ContentEditor.ValueLookupEx作为其控件。因此,您可以创建一个继承自该控件的新控件,并重写Ge
是否要为一个droplist定义多个源?不在标准droplist字段中,但基于droplist创建一个自定义sitecore字段应该不会太困难,该字段从源字段中获取两个参数 这是创建自定义控件的良好资源: droplist控件使用Sitecore.Shell.Applications.ContentEditor.ValueLookupEx作为其控件。因此,您可以创建一个继承自该控件的新控件,并重写GetItems()方法以从源代码读取项 当前的版本如下所示:
protected override Item[] GetItems(Item current)
{
Assert.ArgumentNotNull((object) current, "current");
using (new LanguageSwitcher(this.ItemLanguage))
return LookupSources.GetItems(current, this.Source);
}
因此,您可以使源代码具有由管道(|)分割的2个guid/路径
- 免责声明-此代码未经测试,但应该为您指明正确的方向
protected virtual Item[] GetItems(Item current)
{
Assert.ArgumentNotNull((object) current, "current");
using (new LanguageSwitcher(this.ItemLanguage))
{
var sourceList = this.Source.Split('|');
var items = LookupSources.GetItems(current, source[0]).ToList();
items.AddRange(LookupSources.GetItems(current, source[1]));
return items.ToArray();
}
}