-2

We have a Drupal 8 site that displays a company phone number in a standard block. We'd like to display a different phone number depending on the geographic location of the user (North America, South America, Europe, Asia, etc)

Also, this would be for anonymous users so performance would be important as well.

What are possible ways to handle this?

  • 2
    Hey quantum, asking for the best of something only leads to opinion-based answers. Those questions alway get closed pretty soon. You yourself need to find a way A) to find out where a user comes from (will this happen through some setting from logged in users through the user profile or will this happen through the browser session?) and B) decide where the different phone numbers come into Drupal or if they are just hard-coded in either PHP or JS. Finally you need to get something and running. And ask a question if something's not working. 🙂 – leymannx Jan 6 at 20:55
  • Getting the geo location of a user also isn't necessarily Drupal-related at all. – leymannx Jan 6 at 20:57
  • The question doesn't explain what problem you have when you try to implement what you described. It's not clear what you mean by standard block. Is it a static block created from the UI, or a block implemented by a module? In the first case, it would be quite hard to change the phone number shown to users; in the latter case, it's quite easy. As for performance, it's sufficient to cache the information and invalidate the cache when the location changes. – kiamlaluno Jan 6 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.