Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have installed the locator package and after some messing managed to get it to work.
I want to use the bodyText in the infoWindow popup.
e.g.:
var myHtml = "<h2><xsl:value-of select="@nodeName"/></h2>";
myHtml += "<xsl:value-of select="bodyText"/>";
But, the bodyText has line breaks in the string, so it breaks the javascript and the map will not show.
Any suggestions how I can easily strip out the unwanted line breaks?
Thanks
Hi Rich,
You can use the normalize-space() function for that, e.g.:
myHtml +='<xsl:value-of select="normalize-space(bodyText)" />';
This will convert all consecutive runs of whitespace characters (spaces, tabs, newlines etc.) into a single space.
If you want to escape the newlines for use in the JavaScript, you can use the Replace extension function:
myHtml +='<xsl:value-of select="umbraco.library:Replace('
', '\n')" />';
/Chriztian
Thanks, that is great. I used the first one and it worked (but crashes if there are any single quotes anywhere in the bodyText).
I am not sure how the second line would work, how does it reference the bodyText?
Ha - yeah, that's a mystery - sorry 'bout that :-)
Here's how to it's supposed to look:
<xsl:value-of select="umbraco.library:Replace(normalize-space(bodyText), '
', '\n')" />
- but you'll have the same problems with quote characters - you'll need to escape the ones that are the same as the one you use around the string (\" for double-quotes or \' for single-quotes).
so in the Replace, I could do
<xsl:value-ofselect="umbraco.library:Replace(normalize-space(bodyText), "'", "\'")"/>
that didn't work due to the mix of single/ double quotes.
the \' breaks it.
This is because the ' will be interpreted as an actual single quote and thus, breaks the code...
You should be able to circumvent it like this:
<xsl:variable name="apos">'</xsl:variable> <xsl:variable name="escaped-apos">\'</xsl:variable> <xsl:value-of select="umbraco.library:Replace(normalize-space(bodyText), $apos, $escaped-apos)" />
is working on a reply...
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.
Continue discussion
Remove line breaks for locator package
I have installed the locator package and after some messing managed to get it to work.
I want to use the bodyText in the infoWindow popup.
e.g.:
var myHtml = "<h2><xsl:value-of select="@nodeName"/></h2>";
myHtml += "<xsl:value-of select="bodyText"/>";
But, the bodyText has line breaks in the string, so it breaks the javascript and the map will not show.
Any suggestions how I can easily strip out the unwanted line breaks?
Thanks
Hi Rich,
You can use the normalize-space() function for that, e.g.:
This will convert all consecutive runs of whitespace characters (spaces, tabs, newlines etc.) into a single space.
If you want to escape the newlines for use in the JavaScript, you can use the Replace extension function:
/Chriztian
Thanks, that is great. I used the first one and it worked (but crashes if there are any single quotes anywhere in the bodyText).
I am not sure how the second line would work, how does it reference the bodyText?
Hi Rich,
Ha - yeah, that's a mystery - sorry 'bout that :-)
Here's how to it's supposed to look:
- but you'll have the same problems with quote characters - you'll need to escape the ones that are the same as the one you use around the string (\" for double-quotes or \' for single-quotes).
/Chriztian
so in the Replace, I could do
that didn't work due to the mix of single/ double quotes.
the \' breaks it.
Hi Rich,
This is because the ' will be interpreted as an actual single quote and thus, breaks the code...
You should be able to circumvent it like this:
/Chriztian
is working on a reply...
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.