Hi,
Yes, searches are made over current selected language. Any ad with title/description marked as written in other language won't be taken into consideration.
***UPDATED with 5th version*** (February, 14 2017)
If you're interested in your searches covering all enabled languages, add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.
5th version (Alerts compatible -no duplicate ads, Multilanguage on User Alerts, solved problem with page language changing)
<?php
function cust_refined_pattern_search($params) {
if (@$params['sPattern'] != '') {
$mSearch = Search::newInstance();
$mSearch->addLocale('%');
$mSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
}
}
osc_add_hook('search_conditions', 'cust_refined_pattern_search');
function cust_alerts_user_dashboard() {
if (Params::getParam('page') == "user" && Params::getParam('action') == "alerts") {
$webUser = new CWebUser;
$aAlerts = Alerts::newInstance()->findByUser( Session::newInstance()->_get('userId'), false );
$user = User::newInstance()->findByPrimaryKey( Session::newInstance()->_get('userId'));
foreach($aAlerts as $k => $a) {
$array_conditions = (array)json_decode($a['s_search']);
$search = new Search();
$search->setJsonAlert($array_conditions);
if (osc_version() > 361) $search->notFromUser(Session::newInstance()->_get('userId'));
$search->addLocale('%');
$search->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
$search->limit(0, 3);
$aAlerts[$k]['items'] = $search->doSearch();
}
$webUser->_exportVariableToView('alerts', $aAlerts);
View::newInstance()->_reset('alerts');
$webUser->_exportVariableToView('user', $user);
}
}
osc_add_hook('before_html', 'cust_alerts_user_dashboard');
?>
4th version (Alerts compatible -no duplicate ads, Multilanguage on User Alerts, problem with page language changing, other bugs)
<?php
function cust_pattern_search_all_locales($params) {
if ($params['sPattern'] != '') {
$mSearch = Search::newInstance();
$mSearch->addLocale('%');
$mSearch->addGroupBy("pk_i_id");
}
}
osc_add_hook('search_conditions', 'cust_pattern_search_all_locales');
function cust_alerts_locale_hack_start() {
if (osc_get_osclass_section() == "alerts") {
View::newInstance()->_exportVariableToView('aUserLocale', Session::newInstance()->_get('userLocale'));
Session::newInstance()->_set('userLocale', '%');
}
}
osc_add_hook('init', 'cust_alerts_locale_hack_start');
function cust_alerts_locale_hack_end($conditions) {
if (osc_get_osclass_section() == "alerts") {
Session::newInstance()->_set('userLocale', View::newInstance()->_get('aUserLocale'));
}
return $conditions;
}
osc_add_filter('sql_search_item_conditions', 'cust_alerts_locale_hack_end');
?>
3rd version (Alerts compatible -no duplicate ads, No multilanguage on User Alerts)
<?php
function cust_pattern_search_all_locales($params) {
$mSearch = Search::newInstance();
if ($params['sPattern'] != '') {
$mSearch->addConditions("d.fk_c_locale_code LIKE '%'");
$mSearch->addGroupBy("pk_i_id");
}
}
osc_add_hook('search_conditions', 'cust_pattern_search_all_locales');
function cust_clean_duplicate_ads_user_alerts() {
$clean_alerts = View::newInstance()->_get('alerts');
if ($clean_alerts) {
foreach ($clean_alerts as $key => $alert) {
$outputArray = array();
$keysArray = array();
foreach ($clean_alerts[$key]['items'] as $innerArray) {
if (!in_array($innerArray['pk_i_id'], $keysArray)) {
$keysArray[] = $innerArray['pk_i_id'];
$outputArray[] = $innerArray;
}
}
$clean_alerts[$key]['items'] = $outputArray;
}
View::newInstance()->_exportVariableToView('alerts', $clean_alerts);
}
}
osc_add_hook('before_html', 'cust_clean_duplicate_ads_user_alerts');
?>
2nd version (Alerts compatible -but including duplicate ads under certain circumstances)
<?php
function cust_pattern_search_all_locales($params) {
$mSearch = Search::newInstance();
if ($params['sPattern'] != '') {
$mSearch->addConditions("d.fk_c_locale_code LIKE '%'");
$mSearch->addGroupBy("pk_i_id");
}
}
osc_add_hook('search_conditions', 'cust_pattern_search_all_locales');
?>
1st version (Alerts uncompatible)
<?php
function cust_pattern_search_all_locales($params) {
$mSearch = Search::newInstance();
if ($params['sPattern'] != '') {
$mSearch->addLocale('%');
$mSearch->addGroupBy("pk_i_id");
}
}
osc_add_hook('search_conditions', 'cust_pattern_search_all_locales');
?>
Regards