Since the multilingual version of CMS is a branch and is not up to date, I've thought about doing an adaptation of the regular templates to support multiple languages.
The idea is to create content blocks for each language within the template. I'm going to use "fr" as another language here
My template looks like this
{getlang} (you'll see below)
{if $weblang == "fr"}
{content block="content_fr"}
{else}
{content}
{/if}
...
{if $weblang == "fr"}
{content block="title_fr" oneline="true" wysiwyg="false"}
{else}
{title}
{/if}
... and something like this to ensure that the template has blocks for menu entries in various languages, although they are not displayed on the template directly...
{if 0}
{content block="menu_fr" oneline="true" wysiwyg="false"}
{/if}
Languages will be put in the URL like this: index.php?page=id&lang=fr
If you set it once in the URL and don't use it anymore afterwards, the system will default to this language using a cookie.
Here is my tag (getlang)
Tag: getlang
/* assigns the variable {$weblang} */
global $gCms;
if (isset($_GET["lang"])) { /* Passed in the url: lang= ... */
$gCms->smarty->assign('weblang', $_GET["lang"]);
setcookie("MYlang", $_GET["lang"]);
} elseif (isset($_COOKIE["MYlang"])) {
$gCms->smarty->assign('weblang', $_COOKIE["MYlang"]);
} else {
setcookie("MYlang", "en");
$gCms->smarty->assign('weblang', "en");
}
Now, the problem is to have the menus in various languages. I'm going to define this tag, that takes a pageID and returns the proper menu text, depending on the language.
Tag: general_menu_title
/* param: pageid, assigns {$current_menu_text} */
global $gCms;
$manager =& $gCms->GetHierarchyManager();
/* $thisPage = $gCms->variables['content_id']; */
$thisPage = intval($params['pageid']);
$currentNode = &$manager->sureGetNodeById($thisPage);
$currentContent =& $currentNode->getContent();
if ($smarty->get_template_vars('weblang') == "en") {
$t_ =$currentContent->MenuText();
} else {
$t_ =$currentContent->GetPropertyValue('menu_' . $smarty->get_template_vars('weblang'));
}
$gCms->smarty->assign('current_menu_text', $t_);
Now, in your menu template, replace $node->menutext by this. In order to get the current pageID, I'm gonna use the capture trick.
the code snippet looks like that
{capture name=MENUNODE}
{$node->id}
{/capture}
{general_menu_title pageid=$smarty.capture.MENUNODE}
and here is a complete basic menu with it... note how I use {$current_menu_text} instead of $node->menutext. All the rest is standard
{if $count > 0}
<ul>
{foreach from=$nodelist item=node}
{capture name=MENUNODE}
{$node->id}
{/capture}
{general_menu_title pageid=$smarty.capture.MENUNODE}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->current == true}
<li><a href="{$node->url}" class="currentpage"{if $node->target ne ""} target="{$node->target}"{/if}> {$current_menu_text} </a>
{elseif $node->parent == true && $node->depth == 1}
<li class="activeparent"> <a href="{$node->url}" class="activeparent"{if $node->target ne ""} target="{$node->target}"{/if}> {$current_menu_text} </a>
{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$current_menu_text}
{elseif $node->type == 'separator'}
<li style="list-style-type: none;"> <hr class="separator" />
{else}
<li><a href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}> {$current_menu_text} </a>
{/if}
{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}
Hope this will help someone
