【问题标题】:how to use umbraco field in xslt file如何在 xslt 文件中使用 umbraco 字段
【发布时间】:2013-01-04 12:16:47
【问题描述】:

我想在 xslt 文件中添加我的 umbraco 字段,我该怎么做。

我的 umbraco 字段是:

<umbraco:Item field="image" useIfEmpty="image" textIfEmpty="/css/images/dog.jpg" runat="server" />

我想在图像 src 字段的 XSLT 文件中使用此字段

    <div class="imgbox">
                        <xsl:variable name="image" select="$post/image"/>


                        <img src="/css/images/dog.jpg" alt="" />
</div>

我如何在图像 src 中添加此字段。

【问题讨论】:

    标签: umbraco umbraco5 umbraco-blog


    【解决方案1】:

    我不确定你的意思,但是如果你想在你的图像源中显示变量“image”的值,你不需要额外的变量“image”,可以直接调用代码下面:

    <img src="{$post/image}" alt="" />
    

    这也取决于 ImageField 是什么类型的字段类型。当您的图像字段是具有硬编码路径的文本框时,上面的示例很有用。 如果使用 MediaPicker 字段,则只能取回图像的 ID,并且需要检索 MediaItem:

    <xsl:variable name="media" select="umbraco.library:GetMedia($post/image, false)" />
    <img src="{$media/umbracoFile}" alt="" />
    

    【讨论】:

      猜你喜欢
      • 2017-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多