vendredi 6 mars 2015

XSL Picture Library File Location



I'm creating a custom XSL template that can be used to show pictures in a gallery format on any list specified. I am having trouble dynamically getting the image location though.


I read the following guide: http://ift.tt/1Np0YP4 which shows code that should allow the image location to be generated from the variables used. However if I use the code specified in the guide within my template:



<xsl:call-template name="PictureThumbnail">
<xsl:with-param name="FileDirRef" select="@FileDirRef" />
<xsl:with-param name="FileLeafRef" select="@FileLeafRef" />
<xsl:with-param name="FileType" select="@FileType" />
<xsl:with-param name="Description" select="@Description" />
</xsl:call-template>


It breaks my content query web part. How can get my XSL to location the image files from a picture library dynamically without the need to hard code the locations? Here is my current code (ItemStyle.xsl).



<xsl:template name="EventPhotoGallery" match="Row[@Style='EventPhotoGallery']" 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>

<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'Title'"/>
</xsl:call-template>
</xsl:variable>


<!-- #Gallery Code
================================================================== -->
<figure>

<img src="{$SiteUrl}/{@FileDirRef}/_w/{concat(substring-before(translate(@FileLeafRef,'QWERTYUIOPASDFGHJKLZXCVBNM','qwertyuiopasdfghjklzxcvbnm'),concat('.',@FileType)),'_',@FileType,'.jpg')}" alt="{@Description}" />
<figcaption>
<h3><xsl:value-of select="$DisplayTitle" /></h3>
</figcaption>
<p> <xsl:value-of select="$SafeImageUrl" /></p>
</figure>


</xsl:template>


As you can see I have the following img tag:



<img src="{$SiteUrl}/{@FileDirRef}/_w/{concat(substring-before(translate(@FileLeafRef,'QWERTYUIOPASDFGHJKLZXCVBNM','qwertyuiopasdfghjklzxcvbnm'),concat('.',@FileType)),'_',@FileType,'.jpg')}" alt="{@Description}" />


This doesn't return the full picture library address though and so doesn't work. How do I get the full address of the images in my picture library??


Thanks








0 commentaires:

Enregistrer un commentaire