首页 > 解决方案 > 通过应用程序中的模板获取内容以呈现问题

问题描述

当我设置了视图时,除非我没有设置内容类型,否则我无法让它吐出内容,那么我可以让文本吐出最少。

但是,当我选择一种内容类型时,什么都没有吐出来,它说它没有演示项目。

未选择内容类型 - 我可以显示要显示的文本,它不会循环遍历我的四个内容或呈现令牌。

https://imgur.com/R5dzLyg

https://imgur.com/KLqIr5H

https://imgur.com/fnakNcw

如果我选择内容类型 - 它只是说没有演示内容

https://imgur.com/UR3DZdp

https://imgur.com/f9EII10

如果我选择演示内容

https://imgur.com/2pJPfoE

如果我选择演示内容而不是内容类型

https://imgur.com/2pJPfoE

我确定我错过了一些小东西。我越多地点击和探索,我就越困惑。我来自 Drupal 背景,所以我喜欢这个想法,并且真的很想像使用 Drupal 站点一样使用 DNN。

感谢您对此的帮助。

标签: 2sxc

解决方案


对于任何为此苦苦挣扎的人,我们发现解决方案是检查该字段是否为空。

<div class="row">
 @foreach(var cont in AsDynamic(App.Data["Homepage Blocks"])){
    <div class="col-md-6 block__wrapper">
        <a href="@(cont.Url != null ? cont.Url : "")">
            <div class="block__contianer" style="background-image: url('@(cont.Image != null ? cont.Image : "")')">
                <div class="block__square">
                    <h2><span style="color:#ffffff;">@(cont.Headline != null ? cont.Headline : "")</span></h2>
                </div>
            </div>
        </a>
    </div>
}
</div>

推荐阅读