【发布时间】:2020-04-29 11:15:54
【问题描述】:
我是第一次使用 Umbraco 8,与 Umbraco 6/7 相比,我遇到了很多问题。
所以我试图在 _Layout 局部视图中渲染一些图像。来自根目录中的项目列表。文档类型如下。
我使用了 _Layout.cshtml 中的查询构建器,最终得到以下内容来迭代徽标。
@{
var selection = Umbraco.Content(Guid.Parse("92c903b5-4772-48d5-8e16-5238e45c1e36"))
.ChildrenOfType("footerLogo")
.Where(x => x.IsVisible());
}
<ul>
@foreach (var item in selection)
{
<li>
<a href="@item.Url">@item.Name</a>
// I added this code and put a breakpoint in VS2019 to inspect the object
@item
// Using the immediate window, this gave me a full object
@item.GetProperty("Logo").GetValue()
我尝试使用
访问 Url 属性 item.GetProperty("Logo").GetValue().Url
但遇到异常
cannot convert from 'method group' to 'HelperResult'
我花了几个小时在谷歌上搜索 Umbraco 8 图像渲染,但没有运气。只是想知道是否有人可以指导我如何获得这些值?
非常感谢 抢
【问题讨论】:
标签: c# model-view-controller razor umbraco8