duanhe4267 2012-08-24 23:02
浏览 15
已采纳

根据一个共享站点结构中的用户位置提供唯一内容(不是翻译)。 (PHP / MySQL)

Some Context:
We currently have 5 versions of our site (US, UK, CA, AU, SG) with TLDs for each. We have just decided to expand this to 10-12 sites that will representing 4 or 5 languages (our current sites are only in English).

We will use the TLD for each country (i.e. www.domain.fr) as well as our “.com” with country and language in the path (i.e. www.domain.com/fr/fr) all pointing to the same site/files and hopefully even using the same CSS file(s).

I think we have resolved how to serve up different text content based on the users locale (zend_translate or, possibly, GetText). However, some of the locations will also need to host unique images or other location-specific content within the established structure (Say, hypothetically, that there are 3 blocks/divs in which we place different “ads” based on users location).

Question:
Is there a PHP/MySQL specific “best way” to serve up some unique content based on user’s location -- all within a single shared site structure? (Please note this is not about translation, but about location specific content)

Example:
A really great example of what we would like to achieve is ikea.com, ikea.pl, ikea.com/pl/pl

  • 写回答

1条回答 默认 最新

  • dtgr3392 2012-08-24 23:12
    关注

    Hypothetically there isn't a PHP/MySQL specific best way.

    The best way, there is, is the way to think it, it all depends on what you need. For your small ads problem, if you are not using any HUGE ADS companies that can target client location, you can use MySQL and create block specific zones for each TLD, so you can run different content in every domain in that block of data.

    Images can be hosted in same place, same directory if they have unique names, and again you can use MySQL to keep track what you have and where.

    eg:

    $myTLD = $_SERVER['SERVER_NAME']; // get host
    $myTLD = preg_replace('#^www\.(.+\.)#i', '$1', $myTLD); // remove www if exists
    switch ($myTLD) {
        case 'example.org':
            include 'banners_for_org.php';
            break;
        case 'example.net':
            include 'banners_for_net.php';
            break;
        default:
            include 'banners_general.php';
    }
    

    (PS: I don't see anything similar from ikea.pl in ikea.com, not even the logo)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?