I need to build some functionality in Umbraco to make it possible to hide certain pages based on users country information.And best of all I want to make it in XSLT so I can hide the pages in the navigation and lists. I can do all the XSLT but dont know if it's possible to get the data I need in.
I can get the user information in the Google load script http://www.google.com/jsapi but is it even possible to pass a JavaScript variable to a XSLT variable on pageload ?
XSLT (server side) is processed before javascript(client side). If you must rely on javascript you can render empty navigation and then fill it with ajax request which include info taken using javascript.
If it is possible you can get info from javascript on first page store it and use on next pages (or redirect to country specific page).
Or you can try create xslt extension which use javascript on serverside, but if it use informations from users browser it may be hard.
Then I can't use my first approach anyway. I just thought it would be easy to use googles api to get the client info. But as I see it it's only accessible through JavaScript.
The hard solution would be to make a C# xslt library that looks on the client IP and convert this to a country info. Google did all that for me.
I remembered reading an article where the author downloaded and embedded an IP-to-Country database in a class library. The resulting dll should be less than 500kb.
Maybe it's something for you, you could leverage the dll in a xslt-extension.
I've build a httpmodule for another cms (Synkron Via) that looks in a database (imported GeoIP data). The module has proper caching, and sets the Country/CountryCode as 2 cookies on the request object, so I guess these could be read from xslt (using xslt extensions).
Hide nodes based on user country information
Hi
I need to build some functionality in Umbraco to make it possible to hide certain pages based on users country information.And best of all I want to make it in XSLT so I can hide the pages in the navigation and lists. I can do all the XSLT but dont know if it's possible to get the data I need in.
I can get the user information in the Google load script http://www.google.com/jsapi but is it even possible to pass a JavaScript variable to a XSLT variable on pageload ?
Anyone done something like this before ?
Cheers.
Søren Linaa
XSLT (server side) is processed before javascript(client side). If you must rely on javascript you can render empty navigation and then fill it with ajax request which include info taken using javascript.
If it is possible you can get info from javascript on first page store it and use on next pages (or redirect to country specific page).
Or you can try create xslt extension which use javascript on serverside, but if it use informations from users browser it may be hard.
Petr
Thanks for your reply Petr.
Then I can't use my first approach anyway. I just thought it would be easy to use googles api to get the client info. But as I see it it's only accessible through JavaScript.
The hard solution would be to make a C# xslt library that looks on the client IP and convert this to a country info. Google did all that for me.
Hi Søren
I remembered reading an article where the author downloaded and embedded an IP-to-Country database in a class library. The resulting dll should be less than 500kb.
Maybe it's something for you, you could leverage the dll in a xslt-extension.
http://www.eggheadcafe.com/articles/20051109.asp
Regards
Jesper Hauge
I've build a httpmodule for another cms (Synkron Via) that looks in a database (imported GeoIP data). The module has proper caching, and sets the Country/CountryCode as 2 cookies on the request object, so I guess these could be read from xslt (using xslt extensions).
Just an idea!
Have a look at this package here I believe is exactly what you are looking for...
http://our.umbraco.org/projects/developer-tools/ip2location-integration
is working on a reply...