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?
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
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))
Hi Shwetha,
I'd swap the methods around... strip the HTML first, then get the first X words...
This way it wont treat any HTML tags as "words".
Cheers, Lee.
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
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.
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.
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?
Cheers, Lee.
is working on a reply...