Page 2 of 3
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Wed Jun 20, 2007 8:35 am
by Pierre M.
Hello,
these pieces of code go inside templates and user defined tags.
Please read the
doc about them.
And have fun.
Pierre M.
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Wed Jun 20, 2007 5:17 pm
by theredspecial
thanks again, will try to make it work and enjoy the power of CMSMS
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sat Jun 30, 2007 3:59 am
by miramardesign
Great Idea!! I've been thinking of going bilingual w/ my cmsms site being in Miami and since I'm bilingual myself. I just never saw how within the framework of cmsms.
miramardesign
[url=http://http:miramardesign.com]http:miramardesign.com[/url]
I code therefore I am.
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Wed Jul 04, 2007 10:38 am
by jsmonzani
Hi all,
You're welcome!
I've used this script on numerous websites now and it seems to work without much problems.
Cheers

Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Fri Jul 06, 2007 2:44 pm
by theredspecial
could you post one or a few url's of these sites?
just to see what it works out like?
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sun Jul 22, 2007 12:22 am
by rockarena666
theredspecial wrote:
could you post one or a few url's of these sites?
just to see what it works out like?
I would like to see that too actually. I've been wondering how a site user can choose his language and I like th solution but I'm not too sure about it. It works for only one page I understand?
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Tue Jul 24, 2007 5:41 pm
by andreTTi
Many thanks for this great tip!
However there is one small detail that I would like som help with. I'm trying to figure out a way to "hide" certain pages in the english version of my site. For example, I want to hide the news section in the english version of my site because the news is only avalible in swedish anyway. By "hide" I mean I don't want it to show up in the menu. I figure that this could be accomplished by leaving the "menu_en" field blank for the page I want to hide and then I could exlude it with a well placed "if-statement" in the menu template. (something like: {if $current_menu_text==""} then don't include this page in the menu..). The problem is I can't figure out how the menu template works so I don't know where to place the "if-statement".
Can anyone please help me with this?
/Andreas
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sun Aug 19, 2007 8:59 pm
by copernic67
I've tried to implement your trick on my cmsms installation (version 1.1)
Everything works fine except when the "general_menu_title" tag has to get the title with another language.
I made some testing and found out the "$smarty->get_template_vars('weblang')" returns the right language but the "$currentContent->GetPropertyValue" isn't returning any value.
The block content names are though correct...
Any idea ?
Has the $currentContent->GetPropertyValue function changed with the new version?
Thanks for your help
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Wed Aug 22, 2007 11:04 pm
by wapcamer
Hi,
Copernic, I ran into the exact same problem. No way to have the menu displayed since all items are empty because of the GetPropertyValue function.
It's pretty unclear where to find the doc about smarty's Content class.
Could you manage to make it work ?
Otherwise the script works just well. good work.
I guess it would be possible to deal with the breadcrumbs the same way as the menu, so I'll post it whenever I get it to work.
Thanks for the help.
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Fri Aug 24, 2007 10:48 pm
by wapcamer
I finally found out that I had a missing in the menu manager so that the right URL wasn't displayed at the right place.
Now I have a wonderfully working bilingual site, both in the two menus and the content.
More I have added a flag thing so that you can switch from one language to the other while staying at the same page.
Simply create a UDT with the following code and place a reference within the template and that's it.
Code: Select all
echo '<div class="langflags">';
$pos = strpos($_SERVER["REQUEST_URI"], "?");
if ( $pos===FALSE){
$sepchar="?";
}
else $sepchar = "";
$pos = strpos($_SERVER["REQUEST_URI"], "&lang=");
if ( $pos===FALSE){
$linkurl=$_SERVER["REQUEST_URI"];
}
else $linkurl= substr($_SERVER["REQUEST_URI"], 0, $pos);
if ($smarty->get_template_vars('weblang') == "en") {
echo '<img src="images/flags/flag_en.gif" />';
}
else {
echo '<a href="'.$linkurl.$sepchar.'&lang=en">';
echo '<img src="images/flags/flag_en.gif" /></a>';
}
echo '  ';
if ($smarty->get_template_vars('weblang') == "fr") {
echo '<img src="images/flags/flag_fr.gif" />';
}
else {echo '<a href="'.$linkurl.$sepchar.'&lang=fr"><img src="images/flags/flag_fr.gif" /></a>';
}
echo '</div>';
That can be improved but since I don't know smarty$, I couldn't easily retrieve the URL of the page so I've retroed it from the server's request uri.
Still it is working and not too difficult to maintain if you are to add another language.
Hope this helps.
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sat Sep 15, 2007 12:40 am
by wapcamer
Here is a modified breadcrumbs function file to have the breadcrumbs in the selected language, using the method described in this topic.
You have to replace the file cmsms/plugins/function.breadcrumbs.php with the following content.
in my case, I use title_fr for the title instead of the getMenu() function.
Enjoy.
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
function smarty_cms_function_breadcrumbs($params, &$smarty)
{
global $gCms;
$manager = &$gCms->GetHierarchyManager();
$thispage = $gCms->variables['content_id'];
$trail = "";
#Check if user has specified a delimiter, otherwise use default
if (isset($params['delimiter'])) {
$delimiter = $params['delimiter'];
} else {
$delimiter = ">>";
}
#Check if user has requested an initial delimiter
if (isset($params['initial'])) {
if ($params['initial'] == "1") {
$trail .= $delimiter . " ";
}
}
$root='##ROOT_NODE##';
#Check if user has requested the list to start with a specific page
if (isset($params['root'])) {
$root = $params['root'];
}
$root_url='';
#Check if user has requested to overrided the root URL
if (isset($params['root_url'])) {
$root_url = $params['root_url'];
}
$endNode = &$manager->sureGetNodeById($thispage);
# build path
if (isset($endNode))
{
$content =& $endNode->getContent();
$path=array($endNode);
$currentNode = &$endNode->getParentNode();
while (isset($currentNode) && $currentNode->getLevel() >= 0)
{
$content = &$currentNode->getContent();
if (isset($content))
{
//Add current node to the path and then check to see if
//current node is the set root
//as long as it's not hidden
if( $content->ShowInMenu() && $content->Active() )
{
$path[] = $currentNode;
}
if (strtolower($content->Alias())!=strtolower($root))
{
//Get the parent node and loop
$currentNode = &$currentNode->getParentNode();
}
else
{
//No need to get the parent node -- we're the set root already
break;
}
}
else
{
//There are more serious problems here, dump out while we can
break;
}
}
if ($root!='##ROOT_NODE##') {
# check if the last added is root. if not, add id
$currentNode = &$manager->sureGetNodeByAlias($root);
if (isset($currentNode))
{
$content = &$currentNode->getContent();
if (isset($content) && (strtolower($content->Alias()) == strtolower($root)))
{
$node = &$manager->sureGetNodeByAlias($root);
if (isset($node)) {
$content = &$node->getContent();
if ($content->Id()!=$thispage)
$path[] = $node; # do not add if this is the current page
}
}
}
}
$classid=isset($params['classid'])?(' class="' . $params['classid'] . '"'):'';
$currentclassid=isset($params['currentclassid'])?(' class="' . $params['currentclassid'] . '"'):'';
# now create the trail (by iterating through the path we built, backwards)
for ($i=count($path)-1;$i>=0;$i--) {
$node = &$path[$i];
if (isset($node))
{
$onecontent = &$node->getContent();
if ($onecontent->Id() != $thispage && $onecontent->Type() != 'seperator') {
if (($onecontent->getURL() != "") && ($onecontent->Type() != 'sectionheader')) {
if ($onecontent->DefaultContent() && false == empty($root_url))
{
$trail .= '<a href="' . $root_url . '"';
}
else
{
$trail .= '<a href="' . $onecontent->getURL() . '"';
}
$trail .= $classid;
$trail .= '>';
if ($smarty->get_template_vars('weblang') == "en") {
$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
}
else $trail .= cms_htmlentities($onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')) !=''?$onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')):$onecontent->Name());
$trail .= '</a> ';
} else {
$trail .= "<span $classid>";
if ($smarty->get_template_vars('weblang') == "en") {
$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
}
else $trail .= cms_htmlentities($onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')) !=''?$onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')):$onecontent->Name());
$trail .= '</span>';
$trail .= ' ';
}
$trail .= $delimiter . ' ';
} else {
if (isset($params['currentclassid'])) {
$trail .= "<span $currentclassid>";
} else {
$trail .= '<span class="lastitem">';
}
if ($smarty->get_template_vars('weblang') == "en") {
$trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name());
}
else $trail .= cms_htmlentities($onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')) !=''?$onecontent->GetPropertyValue('title_' . $smarty->get_template_vars('weblang')):$onecontent->Name());
if (isset($params['currentclassid'])) {
$trail .= '</span>';
} else {
$trail .= '</span>';
}
}
}
}
}
if (isset($params['starttext']) && $params['starttext'] != '')
{
$trail = $params['starttext'] . ': ' . $trail;
}
return $trail;
}
function smarty_cms_help_function_breadcrumbs() {
// tdh added the classid help text
?>
<h3>What does this do?</h3>
<p>Prints a breadcrumb trail .</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{breadcrumbs}</code></p>
<h3>What parameters does it take?</h3>
<p>
<ul>
<li><em>(optional)</em> <tt>delimiter</tt> - Text to seperate entries in the list (default ">>").</li>
<li><em>(optional)</em> <tt>initial</tt> - 1/0 If set to 1 start the breadcrumbs with a delimiter (default 0).</li>
<li><em>(optional)</em> <tt>root</tt> - Page alias of a page you want to always appear as the first page in
the list. Can be used to make a page (e.g. the front page) appear to be the root of everything even though it is not.</li>
<li><em>(optional)</em> <tt>root_url</tt> - Override the URL of the root page. Useful for making link be to '/' instead of '/home/'. This requires that the root page be set as the default page.</li>
<li><em>(optional)</em> <tt>classid</tt> - The CSS class for the non current page names, i.e. the first n-1 pages in the list. If the name is a link it is added to the <a href> tags, otherwise it is added to the <span> tags.</li>
<li><em>(optional)</em> <tt>currentclassid</tt> - The CSS class for the <span> tag surrounding the current page name.</li>
<li><em>(optional)</em> <tt>starttext</tt> - Text to append to the front of the breadcrumbs list, something like "You are here".</li>
</ul>
</p>
<?php
}
function smarty_cms_about_function_breadcrumbs() {
?>
<p>Author: Marcus Deglos <<a href="mailto:md@zioncore.com">md@zioncore.com</a>></p>
<p>Version: 1.7</p>
<p>
Change History:<br/>
1.1 - Modified to use new content rewrite (wishy)<br />
1.2 - Added parameters: delimiter, initial, and root (arl)<br />
1.3 - Added parameter: classid (tdh / perl4ever)<br />
1.4 - Added parameter currentclassid and fixed some bugs (arl)<br />
1.5 - Modified to use new hierarchy manager<br />
1.6 - Modified to skip any parents that are marked to be "not shown in menu" except for root<br />
1.7 - Added root_url parameter (elijahlofgren)<br />
</p>
<?php
}
# vim:ts=4 sw=4 noet
?>
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sat Sep 15, 2007 12:42 am
by wapcamer
As a general remark, it would be better to do the language switch in the getMenu() function, rather than duplicating it in the code.
I myself don't have a clue where to find that function, but that would greatly improve the code.
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Sun Sep 21, 2008 4:48 pm
by snuggere
Hi guys
I am very new to CMS-MS but do like very much the straightforwardness. Since I am Dutch I am, as usual, confronted with having to create multilingual sites. I am very much looking forward to having in in native code in a next release but cannot afford to wait till that time.
I do like the approach used in this thread but am afraid that it will get very complicated to get things right when you need to have multi-lingual facilities in basically all the other content fields; title, menu text, etc.
I am trying a slightly different approach where basically every textfield can be used in this way:
{lang_en}This is my site{/lang_en}{lang_nl}Dit is mijn site{/lang_nl} etc. You get the picture I assume.
I added a translate function that takes care of the translation, i.e. selecting the proper content based on the language, just before it is outputted to the browser.
It is working like I want it to, but I would like to gather some feedback on the feasibility of this approach before I go any further with this.
Tia
Willem
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Tue Sep 23, 2008 1:28 pm
by cyberman
Hi Willem,
welcome at planet CMS made simple

.
Have you tried to use inofficial CMSms multilingual version?
http://dev.cmsmadesimple.org/projects/multilang/
Re: My trick for multilingual pages with regular CMS v1.0.6
Posted: Thu Sep 25, 2008 3:35 pm
by Pierre M.