gpt4 book ai didi

tridion - 从 Tridion 中的 XML 检索类别时出错 (DD4T - MVC)

转载 作者:行者123 更新时间:2023-12-04 21:53:30 24 4
gpt4 key购买 nike

在 DD4T View 中,我试图选择类别内关键字的路径值。

foreach(var category in @Model.Categories)
{
if (category.Title.Contains("Taxonomy"))
{
str = category.Keywords[0].Path;

break;
}
}

但在@Model.Categories 中为空。

Error: Object reference not set to instance of the object.



尽管数据存在于 XML 中。

请建议。

最佳答案

我发现这是 DD4T 中的一个问题。解决方法非常简单:如果您使用组件(或页面)的实现作为模型,而不是接口(interface),它就可以工作。

所以开始你的观点:

@model DD4T.ContentModel.Component

而不是
@model DD4T.ContentModel.IComponent

然后再试一次。

关于tridion - 从 Tridion 中的 XML 检索类别时出错 (DD4T - MVC),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11101919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com