我正在构建自定义内容查询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的新手,所以我可能会错过一个明显的解决方案!
任何帮助非常感谢,
强尼
答案 0 :(得分:4)
这是作弊......它正在对src属性做出假设。但这是它!
<xsl:variable name="EmpPhotoUrl" select="substring-before(substring-after(@EmpPhoto, 'src="'), '"')" />
答案 1 :(得分:1)
鉴于@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" />