Posted by SimonD on September 23, 2012 at 9:37pm
Hi
I am trying to change the content of a block based on the country the visitor to my website is located in. If this is not possible I would like to hide the block from visitors from a certain country or set of countries.
What would be the best way to do this? I have searched through the modules directory but can't find anything that would provide this functionality.
PS. This block is set to only appear on selected url's on my website.
Thanks in advance
Simon
Comments
Context GeoIP
You can probably use Context to define block visibility and use Context GeoIP as a condition. There may be other combinations of modules that can do this.
Thanks for your suggestion
Thanks for your suggestion ArjanLikesDrupal.
Context GeoIp and one of its dependancies GeoIP API are only in dev. This would not be an ideal solution as it is for a production website especially since GeoIP API has "This does not currently work" on its release notes. Do you have any other suggestions?
Any other suggestions would be greatly appreciated. This is not a problem I have had to deal with before.
There is also ip2country that
There is also ip2country that can store the user's country, but I don't know if there are modules that do something with that information.
If Panels is aware of the country associated with a user (via ip2country), you could create a Panels variant with the country-specific block that uses the ip2country data as a condition. You'll have to try if Panels can do that, I would guess it's possible (and since Panels gives you so much flexibility, this may be a good route to investigate).
And development versions are not necessarily unstable, it varies greatly. Maybe the module just needs further testing, or the author didn't have enough time for a proper release, etc. I'd recommend checking the issue queues to get an idea, and also just trying out the module.
Thanks again
Thanks again ArjanLikesDrupal.
I did look at ip2country and read the readme.txt file in the module. The problem with the module is that it only works for authenticated users and not anonymous. I need the functionality for both. I am really stuck with this.
Thanks for pointing out that dev versions aren't neccesarily unstable. GeoIP API did state in the release notes that it doesn't currently work.
Ah, I hadn't looked at it
Ah, I hadn't looked at it closely enough to notice those issues. If this post doesn't result in helpful answers you could try posting in http://groups.drupal.org/location-and-mapping. Good luck!
Thanks again for taking the
Thanks again for taking the time to try and help me ArjanLikesDrupal.
I have looked into the group you directed me to and for some reason I can't login to post a question. It just bounces me to a Access Denied page.
I just found smart ip module which looks like it could do what I want using php if statements in the block body content. However I have no idea how to do it as there appears to be no documentation.
The problem with smart ip is that it would cause anonymous users to bypass the cache.
I think you have to join the
I think you have to join the group first in order to post.
I thought I would have to but
I thought I would have to but I can't even login on Drupal Groups.
@SimonD, Was your issue ever
@SimonD,
Was your issue ever resolved? I am working on a site, and need the functionality of your original post. I have reviewed the various commented links, and I'm unsure as to the best hook implementation for what I hope to do.
How did you accomplish the anonymous users path to - unidentified home? Identified users directed to geoloc of client's physical store locations?
downloaded and populated module and table for ip2country
somewhat lost as to what I need to do next...
considering setting up custom blocks or pages controlled by context filters.
Thanks,
Ryan
I never did resolve the
I never did resolve the problem I had in the way I wanted. I ended up using a solution that was external to drupal to change the content of the blocks.
Sorry I couldn't help.