CMS MADE SIMPLE FORGE

Babel: Multilingual site

 

[#5392] Integration with Search Module

avatar
Created By: IRCF (ircf-web)
Date Submitted: 2010-09-08 10:58

Assigned To:
Resolution: None
State: Open
Summary:
Integration with Search Module
Detailed Description:
Hi,

We made the following hacks to enable displaying/filtering results by lang using
Babel :

In modules/babel/babel.module.php, added a new function :

	function get_lang_by_url($url){
		global $gCms;
		$tmp = explode('/',parse_url($url,PHP_URL_PATH));
		$root_alias = $tmp[1];
		$manager =& $gCms->GetHierarchyManager();
		$languages = $this->getlanguages();
		foreach($languages as $language){
			$currentNode = &$manager->sureGetNodeById($language['root_id']);
			$content =& $currentNode->GetContent();
if (isset($content) && $content->Active() && $root_alias==$content->Alias()){
				$lang = $language['langcode'];
			}
		}
		if(!$lang){
			$deflang = $this->GetPreference("default_language", false);
			if($deflang && array_key_exists( $deflang, $languages ) ) {
				$lang = $deflang;
			}
		}
		return $lang;
	}

in modules/Search/action.dosearch.php, line 376, added the lang attribute to
each result, so it can be used in the search results template :

	if (class_exists(babel)){
		$babel = new babel();
		foreach($newresults as $result){
			$result->lang = $babel->get_lang_by_url($result->url);
		}
	}

Hope it helps someone...

History

Updates

Updated: 2010-09-08 10:58
description: Hi, We made the following hacks to enable displaying/filtering results by lang using Babel : In modules/babel/babel.module.php, added a new function : function get_lang_by_url($url){ global $gCms; $tmp = explode('/',parse_url($url,PHP_URL_ => Hi, We made the following hacks to enable displaying/filtering results by lang using Babel : In modules/babel/babel.module.php, added a new function : function get_lang_by_url($url){ global $gCms; $tmp = explode('/',parse_url($url,PHP_URL_
resolution_id: => 5