Advertisement:

Author Topic: Turn Osclass into SINGLE item description keeping your site Multi-Language  (Read 4894 times)

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Turn Osclass into SINGLE item description keeping your site Multi-Language
« Reply #15 on: November 09, 2015, 03:23:10 pm »
Hi seti,

Yes, that would make this thread obsolete :D
Hi,

Wouldn't it be simpler if osclass just added A third column in the language cpannel setting for Enabled (Publish Ad), instead of just the two default options, Enabled (website), Enabled (oc-admin). That way you can turn off the languages you don't want users to use when publishing ads...

gvido

  • Newbie
  • *
  • Posts: 7
Re: Turn Osclass into SINGLE item description keeping your site Multi-Language
« Reply #16 on: September 09, 2017, 09:24:46 pm »
@SmaRTeY
Hello!
I would like to know is this modifications compatible and correct with osclass 3.7.4?

gvido

  • Newbie
  • *
  • Posts: 7
Re: Turn Osclass into SINGLE item description keeping your site Multi-Language
« Reply #17 on: September 09, 2017, 11:06:01 pm »
 question about step 2.:
I have to add to themes functions.php two codes:
a) Teseo code:
https://forums.osclass.org/3-5-x/search-problem-oc-3-5-3/msg113778/#msg113778

b) Yours code:
Code: [Select]
function AddSearchConditions() {

if (isset($params['sPattern'])) {
$mSearch =  Search::newInstance();
// To enable locale independent search we Add a wildcar for locales with Pattern search
$mSearch->addLocale('%');
}

}
//Add our new search condition to the search conditions used by Osclass
osc_add_hook('search_conditions', 'AddSearchConditions');

am I right?
« Last Edit: September 09, 2017, 11:08:19 pm by gvido »

gvido

  • Newbie
  • *
  • Posts: 7
Re: Turn Osclass into SINGLE item description keeping your site Multi-Language
« Reply #18 on: September 09, 2017, 11:52:09 pm »
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?:
Code: [Select]
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;
        }
    }


« Last Edit: September 10, 2017, 12:01:31 am by gvido »

SmaRTeY

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2519
Re: Turn Osclass into SINGLE item description keeping your site Multi-Language
« Reply #19 on: September 13, 2017, 03:16:01 am »
Hi gvido,

if you follow all the instructions it should work in theory :)
My site is working ok with latest Osclass and this setup but I have made more changes in the mean time.

Regards,
Eric

fre2mansur

  • Hero Member
  • *****
  • Posts: 711
another option that no need to edit core:
Just add this on your function.php

Quote
Code: [Select]
<?php
function cust_pattern_search_current_locale($params) {

    if (@
$params['sPattern']) {
        
$mSearch =  Search::newInstance();
        
$mSearch->addLocale(osc_get_preference('language'));
        
$mSearch->addGroupBy("pk_i_id");
    }
}

osc_add_hook('search_conditions''cust_pattern_search_current_locale');
?>