Copied to clipboard

Flag this post as spam?

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


  • vaibhav 119 posts 139 karma points
    Mar 23, 2011 @ 12:00
    vaibhav
    0

    applying link to string after truncating....

    Hello all....

    I have one news list page .....which shows the list of news aticles written ....

    i am able to show each article in the list in news list page ....this is my code ....

    <?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" xmlns:umbraco.contour="urn:umbraco.contour" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour tagsLib BlogLibrary ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
      <xsl:sort select="@updateDate" order="descending" />
     <!--  <h3 class="headline"> <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </h3> -->
      <div id="newsArticle">
      <!--  <div id="newsImage"><xsl:value-of select="umbraco.library:ReplaceLineBreaks(image)" disable-output-escaping="yes"/></div> -->
        <div id="newsImage"><img src="{./image}" alt="" /></div>
        <div id="newscontentArea">
          <div id="newscontentHeader"><xsl:value-of select="umbraco.library:ReplaceLineBreaks(contentHeader)" disable-output-escaping="yes"/></div>
          <div id="newscontentDate"><xsl:value-of select="umbraco.library:ShortDate(@updateDate, true(), ' - ')"/></div>
          <div><xsl:value-of select="umbraco.library:ReplaceLineBreaks(article)" disable-output-escaping="yes"/></div> /* this is content */
        </div>
      </div>
    </xsl:for-each>

    </xsl:template>

    </xsl:stylesheet>

     

    Now want to show the content up to some extend only ie. say up to 50 characters only .....

    how to do this with the above code ...?

    i want to do some thing like this ....

    <xsl:value-of select="umbraco.library:TruncateString($currentPage/article,60,' >>')"/>

    but i am not able to do this in above code .....

    I also want to add link to   ">>"  so that i can route user to full length article.


  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 23, 2011 @ 13:08
    Tom Fulton
    0

    Hi,

    You could try something like this:
    <div>
     <xsl:value-of select="umbraco.library:TruncateString(umbraco.library:ReplaceLineBreaks(article), 60, '')" disable-output-escaping="yes"/>

     <xsl:if test="string-length(umbraco.library:ReplaceLineBreaks(article)) &gt; 60)">  <!-- only show the link if truncated? -->
      <a href="{umbraco.library:NiceUrl(@id)}"> >> </a>
     </xsl:if>
    </div>   /* this is content */

    Hope this helps,
    Tom

  • vaibhav 119 posts 139 karma points
    Mar 24, 2011 @ 06:27
    vaibhav
    0

    Thanx dude ,

    It all worked for me ....

    I just want to ask that can i enter property insted of "@id" in the link?

  • Pasang Tamang 258 posts 458 karma points
    Mar 24, 2011 @ 07:13
    Pasang Tamang
    1

    Hi,

    As I know umbraco.library:NiceUrl(@id) only gives you result of given page id's url. So what you can do is 

    <a href="{./propertyname}"> >> </a>

    and if you are redirecting to other site then do like this

    <a href="{concat('http://',./propertyname)}"> >> </a>

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft