XLST: Display an Image from a node reference and write it out if Tickbox is selected
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<!-- 1. Assign a vairiable 'isTicked' to the thickbox on the current page -->
<xsl:variable name="isTicked" select="$currentPage/showThumbnailInRightColumn"/>
<!-- 2 Get the Image that the 'thumbnail' (node number) link relates to -->
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/thumbnailImage, 0)" />
<!-- 3 if the tick box is ticked write out the image -->
<xsl:if test="$isTicked ='1'">
<p><xsl:value-of select="string(data [@alias='ShowThumbnailInRightColumn'])"/>
<img src="{$media/umbracoFile}" alt="{$media/altText}" />
</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:template match="/">
<!-- start writing XSLT -->
<!-- 1. Assign a vairiable 'isTicked' to the thickbox on the current page -->
<xsl:variable name="isTicked" select="$currentPage/showThumbnailInRightColumn"/>
<!-- 2 Get the Image that the 'thumbnail' (node number) link relates to -->
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/thumbnailImage, 0)" />
<!-- 3 if the tick box is ticked write out the image -->
<xsl:if test="$isTicked ='1'">
<p><xsl:value-of select="string(data [@alias='ShowThumbnailInRightColumn'])"/>
<img src="{$media/umbracoFile}" alt="{$media/altText}" />
</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Comments
Post a Comment