【问题标题】:How do I access custom TextBox field in a default Blog Post document type?如何访问默认博客文章文档类型中的自定义文本框字段?
【发布时间】:2017-08-02 13:19:23
【问题描述】:

我在 Umbraco 7 中的默认博客文章文档类型中添加了一个名为 excerpt 的文本框字段。当 Umbraco 尝试访问该摘录字段中的数据时,它会报告编译错误。

在我的模板中

@{
    var recentblogpost = Model.Content.Site().FirstChild("BlogPostRepository").Children("BlogPost").Last();
}

@recentblogpost.Name, @recentblogpost.excerpt

获取@recentblogpost.Name@recentblogpost.Url 成功。只有我添加的自定义字段(例如 @recentblogpost.excerpt)不会成功。我已经尝试将大写大小写切换为@recentblogpost.Excerpt

报告的错误

Compiler Error Message: CS1061: 'Umbraco.Core.Models.IPublishedContent' does not contain a definition for 'excerpt' and no extension method 'excerpt' accepting a first argument of type 'Umbraco.Core.Models.IPublishedContent' could be found (are you missing a using directive or an assembly reference?)

【问题讨论】:

    标签: razor umbraco umbraco7


    【解决方案1】:

    这个 sn-p 有效。 @recentblogpost["excerpt"]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      • 1970-01-01
      相关资源
      最近更新 更多