Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 具有多个源的Sitecore Droplist_C#_Asp.net_.net_Content Management System_Sitecore - Fatal编程技术网

C# 具有多个源的Sitecore Droplist

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字段。我希望数据源来自两个Sitecore文件夹项


是否要为一个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/路径

  • 免责声明-此代码未经测试,但应该为您指明正确的方向

为什么不尝试使用Sitecore查询来设置位置,并使用和拆分这两个文件夹

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();
  }
}