0

在 sharepoint 中,我创建了一个内容查询 webpart,它查询列表并以 3 列网格格式显示标题和 ImageURL 字段。

由于一些非常奇怪的原因,代码大部分时间都可以正常工作,并且图像和标题按我的意愿显示在网格中。但是,如果您刷新页面几次,则根本无法找到该图像并将其插入到标记中。标题确实一直显示。

我在 XSL itemStyles.xsl 中创建了我自己的项目样式变量。这是我的代码:

<xsl:template name="customStyle" match="Row[@Style='customStyle']" mode="itemstyle">
      <xsl:variable name="SafeLinkUrl">
          <xsl:call-template name="OuterTemplate.GetSafeLink">
              <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
          </xsl:call-template>
      </xsl:variable>
      <xsl:variable name="SafeImageUrl">
          <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
              <xsl:with-param name="UrlColumnName" select="'ImageURL'"/>
          </xsl:call-template>
      </xsl:variable>
      <div class="item">
          <xsl:if test="string-length($SafeImageUrl) != 0">
                  <a href="{$SafeLinkUrl}">
                    <img class="image customstyle-img" src="{$SafeImageUrl}" title="{@ImageUrlAltText}" />
                  </a>
          </xsl:if>
      </div>
  </xsl:template>

如果有人能提供任何建议,我将不胜感激。

奥利弗

4

1 回答 1

0

出于某种原因,开箱即用的代码复制了 imageURL。以下代码修复了它:

<img class="item_customImage" >
    <xsl:attribute name="src">
        <xsl:value-of select="substring-before(@ImageURL, ',')" />
    </xsl:attribute>
 </img>

于 2017-04-04T10:15:31.903 回答