您可以使用
getLookupSourceItems
-这方面的管道。用一个
Droplink
可以将Sitecore查询指定为源。与
获取查找源项
您可以在运行时更改源代码。以下处理器检查
Treelist
并创建一个Sitecore查询,该查询包括
特雷利斯特
.
public class LookupItemsFromField
{
private const string FromFieldParam = "fromfield";
public void Process(GetLookupSourceItemsArgs args)
{
// check if "fromfield" is available in the source
if (!args.Source.Contains(FromFieldParam))
{
return;
}
// get the field
var parameters = Sitecore.Web.WebUtil.ParseUrlParameters(args.Source);
var fieldName = parameters[FromFieldParam];
// set the source to a query with all items from the other field included
var items = args.Item[fieldName].Split('|');
args.Source = this.GetDataSource(items);
}
private string GetDataSource(IList<string> items)
{
if (!items.Any()) return string.Empty;
var query = items.Aggregate(string.Empty, (current, itemId) => current + string.Format(" or @@id='{0}'", itemId));
return string.Format("query://*[{0}]", query.Substring(" or ".Length));
}
}
您必须在
下拉链接
具有的源
fromfield=<SourceField>
:
最后,您需要配置此管道处理器:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getLookupSourceItems>
<processor patch:before="processor[1]"
type="Website.LookupItemsFromField, Website" />
</getLookupSourceItems>
</pipelines>
</sitecore>
</configuration>