Hi,
I am new to MODx and html actually all together, I am more of a designer. Anyway, I am trying to learn ’cause you gotta start somewhere. I actually have my site up and running in English, and I have all my pages designed any waiting for their translations on the Swedish part.
I found the article Make Multi-Lingual Site on Wiki -
http://wiki.modxcms.com/index.php/Make_Multi_Lingual_Site
Not really being 100% at code, I am feeling rather clueless.
When reading the article, I understand the steps themselves, just not the two most important, the Languages and Redirect sections, I am not sure what information to type in where the author has written in red. The only one I get is the ’$langnames = array(’ part.
I really want to learn this. Can someone please help me and give me a "Make_Multi_Lingual_Site for absolute dummies"??
Thanks,
Leigh
Redirect
Create a new snippet, call it "Redirect" and put the following code inside it:
<?php
$url = $modx->makeUrl($id);
ob_end_clean(); // this will end the output buffer and discard silently what ever was in it
header(
’Location: ’.$url);
?>
Languages
Create another snippet called "Languages" with the following code:
<?php
// get languages info
$tv = $modx->getTemplateVar
(’languages’, "", $modx->documentIdentifier);
$languages = $tv
[’value’];
if (!strlen($languages))
{
return
"";
}
$langnames = array(
"en" => "English",
"se" => "svenska"
);
$output = "";
// get entries in languages list
$entries = explode(",", $languages);
// loop through language entries
for ($e = 0; $e < count($entries); $e++)
{
// seperate into lang code and target document id
list($lang, $targetid) = explode("=", $entries[$e]);
$image = ’
<img src="assets/images/’.$lang.’
.gif" width="16" height="11" border="0" alt="’.$langnames[$lang].
’" />’;
if (strlen($output))
{
$output .=
’ ’;
}
$output .= ’
<a href="’.$modx->makeUrl($targetid).’
">’.$image.
’</a>’;
}
return $output;
?>