Tema: Re: du domenai tas pats turinys bet skirtingom kalbom
Autorius: neklausiu
Data: 2012-05-06 15:46:53
                                                                      
     ______                                             _____         
    /\__  _\ __   /'\_/`\ /\`\                         /\   _`\       
    \/_/\ \//\_\ /\      \\/_/ ____        ___     ____\ \ \/\_\      
       \ \ \\/\ \\ \ \__\ \   /',__\      / __`\  /',__\\ \ \/_/_     
        \ \ \\ \ \\ \ \_/\ \ /\__, `\    /\ \L\ \/\__, `\\ \ \_\ \    
         \ \_\\ \_\\ \_\\ \_\\/\____/    \ \____/\/\____/ \ \____/    
          \/_/ \/_/ \/_/ \/_/ \/___/      \/___/  \/___/   \/___/     
                                                                      
                                                                      
  ____            ___             __                                  
 /\  _`\         /\_ \           /\ \__  __                           
 \ \,\L\_\    ___\//\ \    __  __\ \ ,_\/\_\    ___     ___     ____  
  \/_\__ \   / __`\\ \ \  /\ \/\ \\ \ \/\/\ \  / __`\ /' _ `\  /',__\ 
    /\ \L\ \/\ \L\ \\_\ \_\ \ \_\ \\ \ \_\ \ \/\ \L\ \/\ \/\ \/\__, `\
    \ `\____\ \____//\____\\ \____/ \ \__\\ \_\ \____/\ \_\ \_\/\____/
     \/_____/\/___/ \/____/ \/___/   \/__/ \/_/\/___/  \/_/\/_/\/___/ 
                                                                      
                                    http://www.tim-international.net  

This contribution will let you configure several regional domains of
your one and same osCommerce installation. Search engines loves it.
For advanced users only!

Example:

  www.domain.com - english language shop
  www.domain.fr - french language shop
  www.domain.de - german language shop

######################################################################
########################### INSTRUCTIONS #############################
######################################################################

# 1.1 Virtual hosts

Either set up several top domains or sub domains all mounted to your
one and same osCommerce installation directory. 

Option A - Top domains

  www.domain.com => /home/example/vhosts/domain.com/public_html
  www.domain.fr  => /home/example/vhosts/domain.com/public_html
  www.domain.de  => /home/example/vhosts/domain.com/public_html

Option B - Sub domains

  en.domain.com => /home/example/vhosts/domain.com/public_html
  fr.domain.com => /home/example/vhosts/domain.com/public_html
  de.domain.com => /home/example/vhosts/domain.com/public_html

Options C - Mixed domains

  www.domain.com => /home/example/vhosts/domain.com/public_html
  fr.domain.com => /home/example/vhosts/domain.com/public_html
  de.domain.com => /home/example/vhosts/domain.com/public_html

######################################################################

# 2.1 In catalog/includes/configure.php

*** Find ***

  define('HTTP_SERVER', 'http://www.domain.com');
  define('HTTPS_SERVER', 'http://www.domain.com');
  define('HTTP_COOKIE_DOMAIN', 'www.domain.com');
  define('HTTPS_COOKIE_DOMAIN', 'www.domain.com');

*** Change to ***

  define('HTTP_SERVER', 'http://' . (($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'www.domain.com'));
  define('HTTPS_SERVER', 'http://' . (($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'www.domain.com'));
  define('HTTP_COOKIE_DOMAIN', (($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'www.domain.com'));
  define('HTTPS_COOKIE_DOMAIN', (($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'www.domain.com'));

######################################################################

# 2.2 In catalog/includes/application_top.php
(Note: Skip to 2.2B for sub domain solution)

*** Find ***

// set the language
  if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
    if (!tep_session_is_registered('language')) {
      tep_session_register('language');
      tep_session_register('languages_id');
    }

    include(DIR_WS_CLASSES . 'language.php');
    $lng = new language();

    if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
      $lng->set_language($HTTP_GET_VARS['language']);
    } else {
      $lng->get_browser_language();
    }

    $language = $lng->language['directory'];
    $languages_id = $lng->language['id'];
  }

*** Replace with, and edit domain names ***

// set the language
// BOF: [TiM's osC Solutions] SEO Regional Domains
  if (!tep_session_is_registered('language')) {
    tep_session_register('language');
    tep_session_register('languages_id');
  }

  include(DIR_WS_CLASSES . 'language.php');
  $lng = new language();

  // top domain switch
  switch (str_replace('www.', '', $_SERVER['SERVER_NAME'])) {
    case 'domain.dk':
    case 'dk.domain.com':
      $lng->set_language('da');
      break;
    case 'domain.de':
    case 'de.domain.com':
      $lng->set_language('de');
      break;
    case 'domain.fi':
    case 'fi.domain.com':
      $lng->set_language('fi');
      break;
    case 'domain.fr':
    case 'fr.domain.com':
      $lng->set_language('fr');
      break;
    case 'domain.no':
    case 'no.domain.com':
      $lng->set_language('nb');
      break;
    case 'domain.se':
    case 'se.domain.com':
      $lng->set_language('sv');
      break;
    case 'domain.uk':
    case 'uk.domain.com':
      $lng->set_language('en');
      break;
    default:
      $lng->set_language('en');
      break;
  }

  $language = $lng->language['directory'];
  $languages_id = $lng->language['id'];
// EOF: [TiM's osC Solutions] SEO Regional Domains

______________________________________________________________________

(Optional! If you always want to force language currency.)

*** Find ***

// currency
  if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
    if (!tep_session_is_registered('currency')) tep_session_register('currency');

    if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) {
      $currency = $HTTP_GET_VARS['currency'];
    } else {
      $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
    }
  }

*** Change to ***


// currency
// BOF: [TiM's osC Solutions] SEO Regional Domains
  $currency = LANGUAGE_CURRENCY;
// EOF: [TiM's osC Solutions] SEO Regional Domains

######################################################################

#2.3 In catalog/includes/boxes/langauges.php

*** On line ~27, find ***

  $languages_string = '';
  reset($lng->catalog_languages);
  while (list($key, $value) = each($lng->catalog_languages)) {
    $languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES .  $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';
  }

*** (Option A - Topdomains) Replace with ***

  $languages_string = '';
  reset($lng->catalog_languages);
  while (list($key, $value) = each($lng->catalog_languages)) {
  // BOF: [TiM's osC Solutions] SEO Regional Domains
    switch($key) {
      case 'da':
        $domain_name = 'www.domain.dk';
        break;
      case 'de':
        $domain_name = 'www.domain.de';
        break;
      case 'en':
        $domain_name = 'www.domain.com';
        break;
      case 'fi':
        $domain_name = 'www.domain.fi';
        break;
      case 'fr':
        $domain_name = 'www.domain.fr';
        break;
      case 'nb':
      case 'nn':
        $domain_name = 'www.domain.no';
        break;
      case 'sv':
        $domain_name = 'www.domain.se';
        break;
      default:      
        $domain_name = 'www.domain.com';
        break;
    }
    $languages_string .= ' <a href="http://'. $domain_name .'">' . tep_image(DIR_WS_LANGUAGES . $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';
  // EOF: [TiM's osC Solutions] SEO Regional Domains
  }

######################################################################

DONE! Go HAVE YOURSELF A CUP OF COFFEE.