I've built a header section macro to show the content of two properties within several templates, introText and introImage. This is my XSLT so far, but it's not returning any values into the properties. What have I missed here?
The image now shows up fine (result!) but the introText is showing the whole text including markup as a string. Is there a way that I can render the markup as markup rather than encoded?
I get this...
<p><strong>Welcome to The Master Page</strong></p>
Header section Macro
I've built a header section macro to show the content of two properties within several templates, introText and introImage. This is my XSLT so far, but it's not returning any values into the properties. What have I missed here?
<?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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:variable name="imagePath" select="introImage"/>
<xsl:template match="/">
imagePath = <xsl:value-of select="$imagePath"/><br/>
<nobr>
<xsl:if test="$imagePath != '' ">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="$imagePath"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
<h3><xsl:value-of select="introText"/></h3>
</nobr>
</xsl:template>
</xsl:stylesheet>
UPDATE: I've now done this...
<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"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="imagePath" select="$currentPage/introImage"/>
<xsl:template match="/">
<nobr>
<xsl:if test="$imagePath != '' ">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="$imagePath"/>
</xsl:attribute>
</xsl:element>
</xsl:if>
<h3><xsl:value-of select="$currentPage/introText"/></h3>
</nobr>
</xsl:template>
</xsl:stylesheet>
The image now shows up fine (result!) but the introText is showing the whole text including markup as a string. Is there a way that I can render the markup as markup rather than encoded?
I get this...
<p><strong>Welcome to The Master Page</strong></p>
Hi Keith,
I think you have to use the disable-output-escaping="yes" attribute on your xsl:value-of element. So this should do it:
Cheers,
Michael
Thanks Michael,
That was spot-on!
Great :-)
Can you maybe mark the post as solution, so that others having the same issue can find it easier?
Thx & Cheers!
Michael.
I tried to High five you but I don't have enough Karma yet :o(
Yep, you need 70 karma to be able to High five...
Thanks for the thought :-)
Cheers,
Michael.
is working on a reply...