Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all,
Let me describe what I have and what I want to do.
I have some pages (articles):
"Codegarden 09" and "CWS2 is released"
Each of them are the same document type with "Content" tab in Generic properties:
At Content section it looks like this:
So I have fields:
- "News description" with alias "newsdescription" and type "Textbox multiple"
- "News text" with alias "newstext" and type "Richtext editor"
I want to out put content of this two fields on a new page. I use for this macro/xslt:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " ">]><xsl:stylesheetversion="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="itemsToDisplay" select="30" /> <xsl:template match="/"> <xsl:choose> <xsl:when test="$currentPage/@id=2878"><!-- ***************************** Display events for 'EVENTS' page ********************************************************--> <ul style="list-style-type:none;"> <xsl:for-each select="$currentPage/ancestor-or-self::node/node [@id = '2886']/node"> <xsl:sort select="data [@alias = 'date']" order="descending"/> <xsl:if test="position() <= $itemsToDisplay"> <li style="margin-bottom:6px;"> <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias = 'date'], 'dd⁄MM⁄yyyy')"/><br /> <b><xsl:value-of select="data [@alias = 'newsheader']"/></b> <p>Parameter "newsdescription": <xsl:value-of select="data [@alias = 'newsdescription']"/><br /><br /> <p>Parameter "newstext ": <xsl:value-of select="data [@alias = 'newstext']"/> </p> </li> </xsl:if> </xsl:for-each> </ul> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </xsl:template></xsl:stylesheet>
And the result is:
QUESTION:
why content from "News description" field outputs correctly and content from "News text" field outputs wrong?
Is it a difference in types of properties or else?
What to do to output text and images that published in "News text" field in a new page, using xslt?
Thank you!
XSLT values are escaped when output - this needs to be disabled for any rich-text content as it includes HTML tags:
<xsl:value-of select="data [@alias = 'newstext']" disable-output-escaping="yes" />
thank you very much!
can you recomend sources to avoid such mistakes in future? Because I know only this forum.
This is more of an XSLT 'gotcha' rather than something specific to Umbraco, though there are some solutions to common XSLT problems in the web-developer section of the wiki - Useful tips and snippets.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to output content from richtext editor using xslt?
Hi all,
Let me describe what I have and what I want to do.
I have some pages (articles):
"Codegarden 09" and "CWS2 is released"
Each of them are the same document type with "Content" tab in Generic properties:
At Content section it looks like this:
So I have fields:
- "News description" with alias "newsdescription" and type "Textbox multiple"
- "News text" with alias "newstext" and type "Richtext editor"
I want to out put content of this two fields on a new page. I use for this macro/xslt:
And the result is:
QUESTION:
why content from "News description" field outputs correctly and content from "News text" field outputs wrong?
Is it a difference in types of properties or else?
What to do to output text and images that published in "News text" field in a new page, using xslt?
Thank you!
XSLT values are escaped when output - this needs to be disabled for any rich-text content as it includes HTML tags:
thank you very much!
can you recomend sources to avoid such mistakes in future? Because I know only this forum.
This is more of an XSLT 'gotcha' rather than something specific to Umbraco, though there are some solutions to common XSLT problems in the web-developer section of the wiki - Useful tips and snippets.
is working on a reply...