sharepointxsltcqwp

Sharepoint ItemStyle.xsl for CQWP using images from a content type


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


Solution

  • 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=&quot;'), '&quot;')" />