Copied to clipboard

Flag this post as spam?

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


  • Shwetha Shankar 21 posts 41 karma points
    May 19, 2011 @ 15:37
    Shwetha Shankar
    0

    uComponents.strings.GetFirstWords

    Hi,

    I am trying to output a news feed and I want to display only the first 10 words in the feed on the front page, after which I want the text to be appended with '...'. I have tried using uComponents.Strings.GetFirstWords() with no luck. (I have downloaded the uComponents package and installed it in Umbraco and made the config changes to ~/config/xsltExtensions.config file.

    When I type in the following line in the xslt - umbraco.library.StripHTML(uComponents.Strings.GetFirstWords(String, Int32, String)), the Xslt does not save and I receive an error that there is an error on this line. What am I doing wrong?

    I am grateful for any assistance with this.

    Thanks,
    Shwetha

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    May 19, 2011 @ 18:36
    Morten Bock
    1

    Looks liek a syntax error. You should use a colon ":" before the method call. Lik this:

    umbraco.library:StripHTML(uComponents.Strings:GetFirstWords(String, Int32, String))

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    May 19, 2011 @ 18:49
    Lee Kelleher
    0

    Hi Shwetha,

    I'd swap the methods around... strip the HTML first, then get the first X words...

    <xsl:value-of select="ucomponents.strings:GetFirstWords(umbraco.library:StripHTML($currentPage/bodyText), 10, '...')" />

    This way it wont treat any HTML tags as "words".

    Cheers, Lee.

  • Craig100 1136 posts 2523 karma points c-trib
    Jun 27, 2011 @ 18:50
    Craig100
    0

    When I try that I get the following error when saving the XSLT:

    Error occured

    Error in XSLT at line 79, char 11

    78:       <p>
    79: >>>   <xsl:value-of select="ucomponents.strings:GetFirstWords($description, 100)"/> <<<
    80:       </p>
    81:

    I have ucomponents V1.0 installed in an Umbraco 4.5 site.

    Any ideas why it won't save?

    Cheers,

    Craig

     

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jun 27, 2011 @ 18:54
    Lee Kelleher
    0

    Hi Craig,

    Does it give you any more detailed error message?

    It's most likely to do with the "$description" variable - but not sure without seeing more of your XSLT snippet.

    Cheers, Lee.

  • Craig100 1136 posts 2523 karma points c-trib
    Jun 27, 2011 @ 19:07
    Craig100
    0

    Hi,

    All I'm doing is replacing this line which works fine:

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

    So I don't think it's the $description variable. 

    What I put up ealier is the only error message I get.

    The config file looks like this:- 

    <XsltExtensions>

      <ext assembly="umbraco.editorControls" type="umbraco.editorControls.tags.library" alias="tagsLib">

      </ext>

      <ext assembly="Umlaut.Umb.Blog" type="Umlaut.Umb.Blog.BlogLibrary" alias="BlogLibrary">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Cms" alias="ucomponents.cms">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Dates" alias="ucomponents.dates">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.IO" alias="ucomponents.io">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Media" alias="ucomponents.media">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Members" alias="ucomponents.members">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Nodes" alias="ucomponents.nodes">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Search" alias="ucomponents.search">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Strings" alias="ucomponents.strings">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Urls" alias="ucomponents.urls">

      </ext>

      <ext assembly="uComponents.Core" type="uComponents.Core.XsltExtensions.Xml" alias="ucomponents.xml">

      </ext>

    </XsltExtensions>

    Even though I downloaded and installed the V2 ucomponents over the V1, it still reports V1 when I look at the installed packages.

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Jun 27, 2011 @ 23:41
    Lee Kelleher
    0

    Hi Craig,

    Ah ok, yeah it will be v2.x ... with it showing v1.0 is due to how Umbraco handles package upgrades in the back-office.

    With the GetFirstWords call, could try to add the extra parameter for the 'appender', see if that works?

    <xsl:value-of select="ucomponents.strings:GetFirstWords($description, 100, '...')"/>

    Cheers, Lee.

  • 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