4) Make sure categories are translated correctly when switching language on website while being on search result page. Thanks to teseo's help the following functions fix an issue with translation related to url change. Place the following two functions in your theme's "functions.php" :
Code: [Select]
// Two custom functions used to make search-category-result language switch work as long as core is not fixed!
// Credits go to teseo
// Theme needs following change:
// You need to replace in your theme "osc_change_language_url" with the other new function, "cust_change_language_url".
function cust_change_language_url($locale) {
$url = osc_change_language_url($locale);
if( osc_rewrite_enabled() && osc_is_search_page() ) {
$cats = osc_search_category();
if(isset($cats[0])) {
return $url . '/?category=' . $cats[0];
}
}
return $url;
}
function cust_on_change_language_translate_categories() {
$params = Params::getParamsAsArray();
if(isset($params['page']) && isset($params['category'])) {
if ($params['page'] == 'language' && $params['category']) {
$translateCat = new DAO();
$translateCat->dao->select('s_slug');
$translateCat->dao->from(DB_TABLE_PREFIX.'t_category_description d');
$translateCat->dao->join(sprintf("(SELECT fk_i_category_id
FROM %st_category_description
WHERE s_slug = '%s') id", DB_TABLE_PREFIX, $params['category']), "d.fk_i_category_id = id.fk_i_category_id", "INNER");
$translateCat->dao->where(sprintf("d.fk_c_locale_code = '%s'", $params['locale']));
$result = $translateCat->dao->get();
$result = $result->row();
if ($result) $_SERVER['HTTP_REFERER'] = str_replace($params['category'], $result['s_slug'], $_SERVER['HTTP_REFERER']);
}
}
}
osc_add_hook('init', 'cust_on_change_language_translate_categories');
Make sure you also check your theme and change the "osc_change_language_url" into the new function name!
question:
"osc_change_language_url" this function contains also
oc-includes\osclass\gui\footer.php
have I change that file too?
oc-includes\osclass\helpers\hDefines.php contains function:
this function I have to remove?:
function osc_change_language_url($locale) {
if ( osc_rewrite_enabled() ) {
return osc_base_url() . osc_get_preference('rewrite_language') . '/' . $locale;
} else {
return osc_base_url(true) . '?page=language&locale=' . $locale;
}
}