Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Søren Linaa 255 posts 208 karma points
    Apr 16, 2010 @ 11:07
    Søren Linaa
    0

    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

  • Petr Snobelt 923 posts 1535 karma points
    Apr 16, 2010 @ 11:56
    Petr Snobelt
    0

    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

  • Søren Linaa 255 posts 208 karma points
    Apr 16, 2010 @ 12:58
    Søren Linaa
    0

    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.

     

  • Jesper Hauge 298 posts 487 karma points c-trib
    Apr 16, 2010 @ 13:20
    Jesper Hauge
    0

    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

  • Steen Tøttrup 191 posts 291 karma points c-trib
    Apr 16, 2010 @ 13:54
    Steen Tøttrup
    0

    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!

     

  • Spyros Spyriadis 46 posts 70 karma points
    Oct 07, 2011 @ 11:27
    Spyros Spyriadis
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft