We're running Umbraco 4.5.2 on .NET 3.5, and have a question re: efficiency. Set up: i have a phone number in a session variable that I'd like to display without any formatting. For example:
Just in case you decide to keep the formatting (for whatever reason) there's a nifty built-in function you can use for exactly this purpose - it's called translate() and it does a tricky little business of replacing characters in strings. You can google it to get the nitty gritty on it, but for your example you'd do this:
What's more efficient?
We're running Umbraco 4.5.2 on .NET 3.5, and have a question re: efficiency. Set up: i have a phone number in a session variable that I'd like to display without any formatting. For example:
<xsl:value-of select="umbraco.library:Session('strTollFree')" />
strTollFree could = 1 (888) 555-1212, but what I'd like to display is 18885551212.
I figure I could do it with a C# replace as described here:
http://our.umbraco.org/wiki/reference/xslt/extend-your-xslt-with-custom-functions
or, I could use an XSLT custom replace such as:
http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx
Which is more efficient? This XSLT output could be displayed on every page of our site, so it's going to be run fairly often.
Thanks,
- Al
What about storing the phone number formatted as you want in a second session variable?
Just my two cents ;-)
Agree with Thomas, just store the non formatted phone number in the session, and retrieve it from xslt in whatever page, no need for extra calls.
Cheers,
/Dirk
Funny, right in front of me and didn't see it. Thanks guys!
Hi Al,
Just in case you decide to keep the formatting (for whatever reason) there's a nifty built-in function you can use for exactly this purpose - it's called translate() and it does a tricky little business of replacing characters in strings. You can google it to get the nitty gritty on it, but for your example you'd do this:
/Chriztian
That translate function will come in handy down the road. Much appreciated.
- Al
is working on a reply...