简体   繁体   中英

Serving up unique content (not translations) based on user location within one shared site structure. (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 (ie www.domain.fr) as well as our “.com” with country and language in the path (ie 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

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM