Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ol 7 posts 27 karma points
    Dec 07, 2010 @ 13:09
    Ol
    0

    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:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <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="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() &lt;= $itemsToDisplay">
                      <li style="margin-bottom:6px;">
                            <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias = 'date'], 'dd&#8260;MM&#8260;yyyy')"/><br />
                            <b><xsl:value-of select="data [@alias = 'newsheader']"/></b>
                <p>Parameter &#34;newsdescription&#34;:&nbsp;<xsl:value-of select="data [@alias = 'newsdescription']"/><br /><br />
                <p>Parameter &#34;newstext       &#34;:&nbsp;<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!

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Dec 07, 2010 @ 14:47
    Ismail Mayat
    0

    You need to escape the content of newstext field so you need to do

    <xsl:value-of select="data [@alias = 'newstext']disable-output-escaping="yes"/>

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft