【问题标题】:In Sitecore, how does the Glass Mapper Editable feature work when iterating through a collection of objects?在 Sitecore 中,Glass Mapper Editable 功能在遍历对象集合时如何工作?
【发布时间】:2015-01-29 12:28:30
【问题描述】:

我正在使用 Glass Mapper v3.2.3 和 Sitecore v7.5。我在this tutorial 中看到处理像 MultiList 这样的字段并取回可以在子布局上迭代的对象列表是多么容易,如下所示:

<ul class="thumbnails">
    <% foreach (var news in Model.News)
       { %>
    <li class="span3">
        <div class="thumbnail">
            <img src="<%=news.FeaturedImage.Src  %>" alt="<%=news.FeaturedImage.Alt %>">
            <h4>
                <a href="<%=news.Url %>">
                    <%=news.Title %>
                </a>
            </h4>
            <p><%=news.Abstract %></p>
        </div>
    </li>

    <% } %>
</ul>

我还看到在 this tutorial 中使用 Glass 中的可编辑功能是多么容易。但是当我遍历对象列表时,我无法弄清楚如何使上述代码中的字段可编辑。 Editable 功能似乎只适用于底层模型。

在上面的代码中,我想让新闻 Feature Image、Title 和 Abstract 都可以编辑。这甚至可以使用 Glass Mapper 吗?

【问题讨论】:

    标签: sitecore sitecore7 glass-mapper sitecore7.5


    【解决方案1】:

    像这样:@Editable(news, x=&gt;x.Title)

    【讨论】:

    • 谢谢。很简单。我应该知道的。 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多