
Originally Posted by
DML73
Thanks so much tonibarcelona, that was almost exactly what I was looking for. The only difference between your solution and my site is that my site is setup like this:
www.mysite.es/es/blahblah <-- for spanish
and
www.mysite.co.uk/en/blahblah <-- for english
As you can see, I am using two different domains, .es for spanish and .co.uk for english, and also the sub-folders for each language.
How could your code be modified to solve this problem? (unfortunately Im not a programmer).
Glad to help you. Ok, let´s assume that you main domain is the .co.uk. Try this:
Code:
$tmp_lng = new language();
reset($tmp_lng->catalog_languages);
foreach($tmp_lng->catalog_languages as $cat_lng) {
$lengua_sql = $db->Execute("select languages_id from " . TABLE_LANGUAGES . " where code = '" . $cat_lng['code'] . "'");
$codigo_de_lengua=$lengua_sql->fields['languages_id'];
if (isset($_GET['cPath'])) {
$ceon_por_lengua_sql = "select uri from " . TABLE_CEON_URI_MAPPINGS . " where uri IS NOT NULL and main_page='index' and associated_db_id=".$current_category_id." and current_uri=1 and language_id='" .$codigo_de_lengua."'";
$ceon_por_lengua_query = $db->Execute($ceon_por_lengua_sql)->fields['uri'];
}
else if (isset($_GET['manufacturers_id']) ){
$marca_a_buscar="'manufacturers_id=".(int)$_GET['manufacturers_id']."'";
$ceon_por_lengua_sql = "select uri from " . TABLE_CEON_URI_MAPPINGS . " where uri IS NOT NULL and main_page='index' and query_string_parameters=".$marca_a_buscar." and current_uri=1 and language_id='" .$codigo_de_lengua."'";
$ceon_por_lengua_query = $db->Execute($ceon_por_lengua_sql)->fields['uri'];
}
if ($ceon_por_lengua_query!=''){
if ($cat_lng['code']==DEFAULT_LANGUAGE){echo '<link rel="alternate" href="http://www.mysite.com.co.uk' . $ceon_por_lengua_query. '" hreflang="x-default" />';}
else if ($cat_lng['code']=='es'){echo '<link rel="alternate" href="http://www.mysite.es' . $ceon_por_lengua_query. '" hreflang="es" />';}
else if ($cat_lng['code']=='en'){echo '<link rel="alternate" href="http://www.mysite.co.uk' . $ceon_por_lengua_query. '" hreflang="en" />';}
else '<link rel="alternate" href="http://www.mysite.co.uk' . $ceon_por_lengua_query. '" hreflang="' . $cat_lng['code'] . '" />'.PHP_EOL;
}
}
I haven´t tested, so please report if it works.
I have a question for you: Do you run both domains with the same installation.? If so, how do yo do it, with the multisite mod?
Bookmarks