I'm currently trying to parse through the bodyText of a document with several [link]http://www.youtube.com[/link] can occur. These should be "transformed" into regular links like: <a href="http://www.youtube.com" target="_blank">http://www.youtube.com</a>;
While it gets the link just fine, it only takes the first [link][/link] in the bodyText, and basically skips all the others (if there's more than one [link][/link] in the bodyText)
Is there a better way to do this? :-) The [link][/link] thing is required because it's written from a mobilephone that can't handle regular links (don't ask me why!)
Any XSLT gurus out there that can shed some light on this?
Take a look at the Replace() extension function in the umbraco.library namespace. If you want to do this with XSLT you need to google for "recursive templates" to see how you'd do something like this.
Converting links
Hi all,
I'm currently trying to parse through the bodyText of a document with several [link]http://www.youtube.com[/link] can occur. These should be "transformed" into regular links like: <a href="http://www.youtube.com" target="_blank">http://www.youtube.com</a>;
So far I have this XSLT:
<ul>
<xsl:for-each select="$currentPage/* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">
<li>
<xsl:if test="contains(current()/bodyText, '[link]')">
<xsl:variable name="url">
<xsl:variable name="startUrl" select="substring-after(current()/bodyText, '[link]')" />
<xsl:variable name="endUrl" select="substring-before($startUrl, '[/link]')" />
<xsl:value-of select="$endUrl" />
</xsl:variable>
<xsl:value-of select="$url" />
</xsl:if>
</li>
</xsl:for-each>
</ul>
While it gets the link just fine, it only takes the first [link][/link] in the bodyText, and basically skips all the others (if there's more than one [link][/link] in the bodyText)
Is there a better way to do this? :-) The [link][/link] thing is required because it's written from a mobilephone that can't handle regular links (don't ask me why!)
Any XSLT gurus out there that can shed some light on this?
Thanks in advance!
All the best,
Bo
Hi Bo,
Take a look at the Replace() extension function in the umbraco.library namespace. If you want to do this with XSLT you need to google for "recursive templates" to see how you'd do something like this.
/Chriztian
Chriztian,
A recursive remplate solved it! :-) Thanks a lot !
Excellent! That's exactly what I like to hear :-)
/Chriztian
is working on a reply...