Sharepoint ItemStyle.xsl,用于使用内容类型中的图像的 CQWP

发布于 2024-07-13 10:39:57 字数 885 浏览 7 评论 0原文

我正在构建一个自定义内容查询 Web 部件来显示员工内容类型的汇总信息。 此内容类型有一个名为 EmpPhoto 的发布图像网站栏。 我的 CQWP 运行良好,我需要的所有网站栏都可用。

我现在正在创建一个自定义 xsl 模板来正确呈现信息,但在使用 EmpPhoto 图像时遇到困难。

如果我使用代码:

<xsl:value-of select="@EmpPhoto" disable-output-escaping="yes" />

...我会得到正确渲染的图像,这很棒。 但是,我想为此图像构建一个 onmouseover 事件,但这种方法行不通。

我想创建一个 xsl 变量来获取实际的图像 URL,然后构建我自己的 html img 并将 onmouseover 写入其中,例如

<xsl:variable name="EmpPhotoUrl">
    <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
        <xsl:with-param name="UrlColumnName" select="@EmpPhoto"/>
    </xsl:call-template>
</xsl:variable>

...

<img src="{$EmpPhotoUrl}" onmouseover="" alt="test" />

但是,这不会从 EmpPhoto 站点列获取 URL。 我是 xsl 新手,所以我很可能会错过一个明显的解决方案!

非常感谢任何帮助,

乔尼

I'm building a custom Content Query Web Part to display rollup information from an employee content type. This content type has a Publishing Image site column called EmpPhoto. My CQWP is working great and all the site columns I need are available.

I am now creating a custom xsl template to render the information correctly but am stuck using the EmpPhoto image.

If I use the code:

<xsl:value-of select="@EmpPhoto" disable-output-escaping="yes" />

... I get a correctly rendered image which is great. However I want to build an onmouseover event for this image and this approach will not work.

I thought to create an xsl variable to grab the actual image URL then build my own html img and write the onmouseover into that e.g.

<xsl:variable name="EmpPhotoUrl">
    <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
        <xsl:with-param name="UrlColumnName" select="@EmpPhoto"/>
    </xsl:call-template>
</xsl:variable>

...

<img src="{$EmpPhotoUrl}" onmouseover="" alt="test" />

This doesn't get the URL from the EmpPhoto site column however. I am new to xsl so I might well be missing an obvious solution!

Any help much appreciated,

Jonny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

指尖微凉心微凉 2024-07-20 10:40:09

鉴于 @EmpPhoto 值只是一个表示 html 图像标签的字符串,您可以将鼠标悬停脚本“注入”到该值中,例如

<xsl:variable name="EmpPhoto"><xsl:value-of select=sub-string(@EmpPhoto) />[and some other code to add the mouseover etc]</xsl:variable>

<xsl:value-of select="$EmpPhoto" />

Given the @EmpPhoto value is just a string representing an html image tag, you could "inject" the mouseover script into the value, e.g.

<xsl:variable name="EmpPhoto"><xsl:value-of select=sub-string(@EmpPhoto) />[and some other code to add the mouseover etc]</xsl:variable>

<xsl:value-of select="$EmpPhoto" />
眼泪淡了忧伤 2024-07-20 10:40:08

这是作弊......并且它对 src 属性做出假设。 但它就在这里!

<xsl:variable name="EmpPhotoUrl" select="substring-before(substring-after(@EmpPhoto, 'src="'), '"')" />

This is cheating... and it's making assumptions about the src attribute. But here it is!

<xsl:variable name="EmpPhotoUrl" select="substring-before(substring-after(@EmpPhoto, 'src="'), '"')" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文