Sharepoint ItemStyle.xsl for CQWP using images from content type

I am creating a custom content request web part to display collapse information from an employee content type. This type of content has an image publishing site column called EmpPhoto. My CQWP works fine, and all the site columns available to me are available.

Now I am creating my own xsl template to display information correctly, but am stuck using EmpPhoto image.

If I use the code:

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

... I get a properly designed image that is great. However, I want to create an onmouseover event for this image, and this approach will not work.

I thought to create an xsl variable to capture the actual URL of the image, and then create my own html-img and write onmouseover to this, for example.

<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 does not get the URL from the EmpPhoto site column. I'm new to xsl, so I might miss the obvious solution!

Any help is greatly appreciated

Johnny

+5
source share
2 answers

This is a hoax ... and he makes assumptions about the src attribute. But here it is!

<xsl:variable name="EmpPhotoUrl" select="substring-before(substring-after(@EmpPhoto, 'src=&quot;'), '&quot;')" />
+4
source

Given the value of @EmpPhoto - this is just a string representing the tag of an html image, you can "insert" the script mouse pointer into the value, for example.

<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" />
+1
source

All Articles