Copied to clipboard

Flag this post as spam?

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


  • ridi 71 posts 103 karma points
    Aug 17, 2010 @ 03:54
    ridi
    0

    News teaser,It displayed the title but not the bodytext

    Dear All,

    today i creates the news teaser with the xslt like this

    <?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" 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"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>
    <xsl:variable name="maxItems" select="/macro/maxItems"></xsl:variable>

     

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
    <xsl:sort select="@createDate" order="descending"/>
    <xsl:if test="position() &lt;= $maxItems">
     <h3>
      <a href="{umbraco.library:NiceUrl(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
     </h3>
     <br></br>
     <p>
           <xsl:value-of select="substring(umbraco.library:StripHtml(data [@alias = 'bodyText']),1,255)" disable-output-escaping="yes"/> 
         </p>
    </xsl:if>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

     

    the problem is, its only display the titles of the news but not the bodytext, any clue about my xslt is highliy appreciated..

    thanks

     

     

  • Sascha Wolter 615 posts 1101 karma points
    Aug 17, 2010 @ 08:16
    Sascha Wolter
    0

    Hi ridi,

    In the new schema you don't need to use the data[@alias=';] bit anymore. Try this:

    <xsl:variable name="bodyText" select="umbraco.library:StripHtml(./bodyText)" />
    <xsl:value-of select="substring($bodyText, 1, 255)" />

    I don't think you need the disable-output-escaping attribute since you are stripping out all html. If the above works you can merge the two lines into one as you like.

    Hope that works,
    Sascha

     

  • ridi 71 posts 103 karma points
    Aug 17, 2010 @ 10:32
    ridi
    0

    it's working like a charm, thanks Sascha :)

  • Sascha Wolter 615 posts 1101 karma points
    Aug 17, 2010 @ 10:39
    Sascha Wolter
    0

    Great, glad to hear that! :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies