Copied to clipboard

Flag this post as spam?

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


  • Stef Dijksman 9 posts 29 karma points
    Dec 14, 2010 @ 13:24
    Stef Dijksman
    0

    umbraco news items text isnt found (CWS)

    Hey!

    i wanted to make a news page on wich i could see just 100 characters of the post and then had  to click on the title to read on. i found the Umbraco Creative Website Starter - 2.0.2 and it had just what i wanted. now when i copied the xslt and changed the part from wheren it should get the html in the xslt, it didnt work.. so i changed the for each and it now shows the date and title of the article but not the 100 chars of the article itself.. soo my question was .. whats wrong with it?.. i guess it is in the part that tries to strip the html and then truncates it..

    thanks in advance!


    heres my 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:param name="MaxNoChars" select="100" />
        <xsl:param name="level" select="2" />
        <xsl:template match="/">

            <div class="newsList clearfix">
              <p>testing 1</p>
                <!--
                =============================================================
                For Each child node of the currentpage
                =============================================================
                -->
                <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
                  <p>testinggg 2</p>
                    <div>
                        <xsl:attribute name="class">
                            <xsl:choose>
                                <xsl:when test="position() mod 3 = 1">
                                    <xsl:text>
                                        first left
                                    </xsl:text>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:text>
                                        left
                                    </xsl:text>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:attribute>
                        
                        <span>
                            <!-- Date Format: 15.12.08 -->
                            <xsl:choose>
                                <xsl:when test="current()/@nodeTypeAlias = 'EventItem'">
                                    <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias='eventDate'], 'dd.MM.yy')"/>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd.MM.yy')"/>                   
                                </xsl:otherwise>
                            </xsl:choose>
                        </span>
                        <h4>
                            <a href="{umbraco.library:NiceUrl(@id)}">
                                <xsl:value-of select="@nodeName" />
                            </a>
                        </h4>
                        <p>
                            <!-- TODO: strip HTML & truncate -->
                            <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(data [@alias='mainTextArea']), $MaxNoChars, '...')" disable-output-escaping="yes" />
                        </p>
                    </div>

                    <!--
                    =============================================================
                    After very 3rd item insert a <br/>
                    =============================================================
                    -->
                    <xsl:if test="position() mod 3 = 0">
                        <br class="clearBoth"/>
                    </xsl:if>
                    
                </xsl:for-each>

            </div>

        </xsl:template>

    </xsl:stylesheet>
  • Kim Andersen 1447 posts 2196 karma points MVP
    Dec 14, 2010 @ 23:51
    Kim Andersen
    0

    Hi Stef

    I think you have mixed some of the legacy XML schema syntax into your XSLT code in the copy/paste phase. So you probably need to change this:

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(data [@alias='mainTextArea']), $MaxNoChars, '...')" disable-output-escaping="yes" />

    to this:

    <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:StripHtml(mainTextArea), $MaxNoChars, '...')" disable-output-escaping="yes" />

    /Kim A

  • Kim Andersen 1447 posts 2196 karma points MVP
    Dec 14, 2010 @ 23:54
    Kim Andersen
    0

    I just re-read your code, and I can see that there's a small problem with the <xsl:choose> you use when rendering the date as well. You might want to change that code to this:

    <xsl:choose>
         <xsl:when test="current()/name() = 'EventItem'">
              <xsl:value-of select="umbraco.library:FormatDateTime(eventDate, 'dd.MM.yy')"/>
         </xsl:when>
         <xsl:otherwise>
              <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd.MM.yy')"/>                  
         </xsl:otherwise>
    </xsl:choose>

    /Kim A

  • Stef Dijksman 9 posts 29 karma points
    Dec 15, 2010 @ 09:11
    Stef Dijksman
    0

    thanks!

    i'll try it out right now! weirdly enough i literally coppied this from the umbraco creative website starter .. so that package must have it wrong too then right?

    i'll let you know if it worked!

     

     

    Stef

  • Stef Dijksman 9 posts 29 karma points
    Dec 15, 2010 @ 09:33
    Stef Dijksman
    0

    hmm.. i just tried the code you gave me and the date gave the following error:

    Error occuredError in XSLT at line 48, char 30
    46:       <!-- Date Format: 15.12.08 -->
    47:       <xsl:choose>
    48: >>>   <xsl:when test="current()/name() = 'EventItem'"> <<<
    49:       <xsl:value-of select="umbraco.library:FormatDateTime(eventDate, 'dd.MM.yy')"/>
    50:       </xsl:when>

    but i dont think i need this code because the date shows up properly. but...... the article works!!

    many many thanks for this because i was really not understanding what was wrong of it.

    Stef

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Dec 15, 2010 @ 19:05
    Kim Andersen
    0

    Ohh sorry Stef. I was a bit to fast there and forgot to delete a small part of the code. The code should look like this:

    <xsl:choose>
         <xsl:when test="name() = 'EventItem'">
              <xsl:value-of select="umbraco.library:FormatDateTime(eventDate, 'dd.MM.yy')"/>
         </xsl:when>
         <xsl:otherwise>
              <xsl:value-of select="umbraco.library:FormatDateTime(@createDate, 'dd.MM.yy')"/>                  
         </xsl:otherwise>
    </xsl:choose>

    You shall remove the current()/ from the code and replace it with name()/. The reason why there's shown a date, is because it's the code inside the otherwise that's shown, because the first test will never be true due to the wrong code. So it's the creation date that's shown, and not the date in the eventDate property.

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft