2sxc - 通过应用程序中的模板获取内容以呈现问题
问题描述
当我设置了视图时,除非我没有设置内容类型,否则我无法让它吐出内容,那么我可以让文本吐出最少。
但是,当我选择一种内容类型时,什么都没有吐出来,它说它没有演示项目。
未选择内容类型 - 我可以显示要显示的文本,它不会循环遍历我的四个内容或呈现令牌。
如果我选择内容类型 - 它只是说没有演示内容
如果我选择演示内容
如果我选择演示内容而不是内容类型
我确定我错过了一些小东西。我越多地点击和探索,我就越困惑。我来自 Drupal 背景,所以我喜欢这个想法,并且真的很想像使用 Drupal 站点一样使用 DNN。
感谢您对此的帮助。
解决方案
对于任何为此苦苦挣扎的人,我们发现解决方案是检查该字段是否为空。
<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>
推荐阅读
- ssh - 如何通过嵌套的 tmux 会话正确设置远程服务器
- javascript - 角度反应形式patchValue或setValue不起作用 - Angular 10
- angular - 将 ng-template 注入组件
- c# - 不支持客户端 GroupBy - 修复
- php - 与我的 API 连接的 PHP If 和 Else 布尔值不起作用
- sql-server - 获取每个用户在 24 个时间段中的每小时通话数据
- security - Kubernetes EncryptionConfiguration 中的 `identity` 提供者提供什么样的安全性?
- javascript - 在谷歌应用脚本中不使用 document.getElementById() 获取文本输入框的值?
- swift - 如何将 pod 集成到 projectname.xcworkscape 中?
- delphi - 如何遍历任何给定集合中的枚举?