作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试弄清楚如何将 Droplink
链接到 Treelist
中的选定项目。我有一个字段 Theme
,即 Treelist
,还有一个字段 MasterTheme
,即 Droplink
。
我应该能够在 Droplink
中选择一个主主题,其中填充了 Treelist
中选定的数据。
我对 Sitecore 还很陌生,而且不熟悉自定义类。
最佳答案
您可以使用getLookupSourceItems
-为此的管道。与 Droplink
您可以指定 Sitecore 查询作为源。并与 getLookupSourceItems
您可以在运行时更改源。以下处理器检查 Treelist
中选择的项目并创建一个 Sitecore 查询,其中包含 Treelist
中选择的所有项目.
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));
}
}
您必须指定 Droplink
中的“源”字段是哪个字段来源为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>
关于sitecore - 如何将 droplink 链接到 Sitecore 中的树列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25784121/
我正在开发一个 voip 调用应用程序。我需要做的是在接到来电时将 Activity 带到前台。我在应用程序中使用 Twilio,并在收到推送消息时开始调用。 问题是我试图在接到任何电话时显示 Act
我是一名优秀的程序员,十分优秀!