[SOLVED] Help modifying {lang} tag

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
peterfarrington
New Member
New Member
Posts: 8
Joined: Wed Jun 03, 2009 10:12 am

[SOLVED] Help modifying {lang} tag

Post by peterfarrington »

Hi

I am the guy working on the multilanguage - multidomain site.

I have the {lang} tag showing flags at the bottom of the page. Presently if a browser clicks on a flag it goes to the correct language version, but the domain stays the same, so the browser can be viewing the Dutch language site but on the .co.uk domain.

I would like to modify the {lang} tag so that it adds a domain reference to the flags. So the dutch flag would have www..nl added to the link.

Can anyone point me to where the {lang} tag is located so that I can modify it.

Thanks

Peter
Last edited by peterfarrington on Wed May 12, 2010 10:24 am, edited 1 time in total.
Peciura

Re: Help modifying {lang} tag

Post by Peciura »

{lang} is ordinary CMSms plugin. You can find it on '/plugins/function.lang.php'
peterfarrington
New Member
New Member
Posts: 8
Joined: Wed Jun 03, 2009 10:12 am

Re: Help modifying {lang} tag

Post by peterfarrington »

Thanks for the pointer.

I have modified the plugin, or rather created a copy and modified it. I am creating a url over the various flags which picks up the correct domain name. So the German flag has...

http://www..de/index.php?page=projects&hl=de_DE

and the French flag has...

http://www..eu/index.php?page=projects&hl=fr_FR

But the problem I am finding is that when the browser reaches that page it automatically redirects to...

http://www..de/index.php?page=home&hl=de_DE etc

So it always goes to the home page, and then I can browse the German site fine.

But the URL in the {lang} plugin looks fine.

Can anyone suggest where this redirection is taking place?

Thanks

Peter
Peciura

Re: Help modifying {lang} tag

Post by Peciura »

Attach plugin you modified to your next message.
Also you will have to modify your tag if you want to upgrade to CMSms-1.7.1-mle-fork (it is being tested ATM).
peterfarrington
New Member
New Member
Posts: 8
Joined: Wed Jun 03, 2009 10:12 am

Re: Help modifying {lang} tag

Post by peterfarrington »

Thanks for your continuing assistance.

I have copied the {lang} tag and created a new one called {lang2} so that I didn't mess anything up with the vanilla installation.

i. I added a line in config_lang which provides a site address for each language. So an excerpt is ...

'text'=>'English',
'site'=>'http://www.waterloo.co.uk',
'locale'=>'en_US.UTF-8'

ii. I modified a small section of the function.lang2.php file.

if($contentobj->DefaultContent() && get_site_preference('root_url_default_content',0))
{
$_url = $config['root_url'].'/?hl=';
}
else
{
$_url = $config['root_url'].'/index.php?'.$config['query_var'].'='.$alias.'&hl=';
}
foreach($hls as $key=>$mle)
{
//if(!in_array($key, $lang_ready)) continue;
$arr_mle[$key] = $mle;
if($hl == $key) $arr_mle[$key]['current'] = true;

$_url2 = $arr_mle[$key]['site'].'/index.php?'.$config['query_var'].'='.$alias.'&hl=';


$arr_mle[$key]['link'] = (!empty($params['urlparam'])) ? $_url.$key.$params['urlparam'] : $_url2.$key;

}


This produces the correct url when I look at the page source. For instance...

http://www..co.uk/newsite/index.php?page=news&hl=en_UK

But as I reported. When I go to this address it automatically redirects to the home page. The .htaccess in the CMSMS root directory is only setting PHP memory limits etc and does no redirection. If I just cut and paste the URL it also goes to the home page.

Is this because I am changing domain and language?

Any suggestions will be very gratefully received. I thought I was nearly there.

Peter
peterfarrington
New Member
New Member
Posts: 8
Joined: Wed Jun 03, 2009 10:12 am

[SOLVED] Help modifying {lang} tag

Post by peterfarrington »

Forgive my stupidity.

I now realise, after many hours of staring at the screen, that I was linking the flags to the root of the site and not to the subdirectory where I have had to install CMSMS. In the root there is a script that checks the domain and redirects to the home page if someone has just entered the bare domain name, and so this was being called.

I have now modified my copy of {lang} so that it goes to the correct subdirectory and it is working fine.

What I need to do now, having got all the flags showing all of the time (which is what the client wants) is to grey out and not link those language variants which do not have content.

Thanks

Peter
Peciura

Re: [SOLVED] Help modifying {lang} tag

Post by Peciura »

This is basic query to check if content is not empty. You should use right $temp_mleblock for each language
global $gCms;
$db = $gCms->GetDb();
$db_reslut = $db->Execute('SELECT `content` ,`prop_name`
FROM `'.cms_db_prefix().'content`, `'.cms_db_prefix().'content_props`
WHERE `content_alias` = ? AND '.cms_db_prefix().'content.content_id='.cms_db_prefix().'content_props.content_id AND '.cms_db_prefix().'content_props.content'.$temp_mleblock.' IS NOT NULL  AND '.cms_db_prefix().'content_props.content ""', array($page_alias));
if($db_result) return TRUE; //content not empty
else return FALSE; // content empty
Locked

Return to “[locked] CMSMS MLE fork”