【问题标题】:Umbraco 8 render image from IPublishedContent来自 IPublishedContent 的 Umbraco 8 渲染图像
【发布时间】: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


    【解决方案1】:

    这是未经测试的,但也许您可以尝试以下方法:

    item.Value("Logo").url()
    

    item.Url
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-15
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多