Different templates for languages

About the template and stylesheet - and changing the menu
Post Reply
Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Different templates for languages

Post by Tata » Sat Mar 28, 2009 10:52 pm

I am working on a webpage which´shall be available in more languages. There won't be the whole content translated in all languages. Some parts of the content are hidden and called into newsboxes. And exactly these newsboxes won't be shown in some languages. Thats why I think to need different templates, where the newsboxes won't be designed.
So I have
[templates]
...[default]
...[default_en]
...[default_de]

and I have this in each template.htm"

Code: Select all

if($sl=='sk') $cf['site']['template']="default";   //defined also in config.php
if($sl=='de') $cf['site']['template']="default_de"; 
if($sl=='en') $cf['site']['template']="default_en";
But something doesn't work. Switching the languages works (the correct content is loaded). But the templates don't change. Only the dafault is loaded. What am I doing wrong?
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Different templates for languages

Post by mvwd » Sat Mar 28, 2009 11:41 pm

Changing the template within the template is just impossible... because you'r asking CMSimple to include a file which has still been included (template.htm).

mvwd.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Different templates for languages

Post by Tata » Sun Mar 29, 2009 7:23 am

Right! This way it can't work. I should think about this. But now (sleeping well this night) I woke up with another solution.
I changed the line in cms.php:

Code: Select all

$pth['folder']['template'] = $pth['folder']['templates'].$cf['site']['template'].'/';
to

Code: Select all

$pth['folder']['template'] = $pth['folder']['templates'].$cf['site']['template'].'_'.$sl.'/';
Now the only I need are templates named e.g.:
[templates]
/[default_sk]
/[default_de]
/[default_en]
/[default_nl] etc.
No other changes and adjustments are needed. The var. in config.php also remains as it was:

Code: Select all

$cf['site']['template']="default";
The same way would it be possible to change the line:

Code: Select all

$pth['file']['template'] = $pth['folder']['template'].'template.htm';
to

Code: Select all

$pth['file']['template'] = $pth['folder']['template'].'template_'.$sl.'.htm';
instead of the previous way and have only:
[templates]
/[default]
//template_sk.htm
//template_de.htm
//template_en.htm
//template_nl.htm etc.
It seems to work well for me. Or is there something wrong with it?
To do: insert a checking if additional language templates exist - if not use the some default template. Maybe today :-)
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: Different templates for languages

Post by Tata » Sun Mar 29, 2009 10:39 am

Seems to work
I extended this code with the //***...//*** part:

Code: Select all

$pth['folder']['templates'] = $pth['folder']['base'].'templates/';
$pth['folder']['template'] = $pth['folder']['templates'].$cf['site']['template'].'/';
//***$pth['folder']['template'] = $pth['folder']['templates'].$cf['site']['template'].'_'.$sl.'/';
if (!file_exists($pth['folder']['template'].'template_'.$sl.'.htm')) {
    $pth['file']['template'] = $pth['folder']['template'].'template.htm';
} else {
    $pth['file']['template'] = $pth['folder']['template'].'template_'.$sl.'.htm';
}
//*** 
and have created:
template.htm for my default language
template_de.htm, template_en.htm etc. for additional languages. Now the page is loaded with "language" template after selecting the language.

If there is a need to use also different images in different templates or different structure of the page, only this change is needed:

Code: Select all

$pth['file']['template'] = $pth['folder']['template'].'template.htm';
to

Code: Select all

$pth['file']['template'] = $pth['folder']['template'].'template_'.$sl.'.htm';
and create separated template folders in name form [default_<language_code>].

If you find something wrong in this, please, let me know.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

kweku
Posts: 90
Joined: Sun Jan 18, 2009 3:37 pm

Re: Different templates for languages

Post by kweku » Thu Jun 25, 2009 2:21 am

hello Tata,

i have read your post with great interest and wonder if you are able to help me with a similar concept.

i have a test site here http://www.insight-design-group.com/imc ... x.php?home

it has a few modest enhancements, and with some help from the cmsimple wizards out there i have been able to assign different banner images for each page with one template - i would like to go one step further and assign a specific template to a specific page.

so for instance...all the pages use ' template.htm' > Now, if you click on ' services ' how can we assign a template such as ' template3col.htm' for example, to be used only for the 'services' page ( +sub-pages ) ?

i imagine the additional template would be in the same folder as the main template, calling on the same stylesheet and images folder. The phyisical difference with this template is that it would have columns as well as other things specific.

ZiPs
Posts: 633
Joined: Thu May 22, 2008 6:17 pm
Location: Faxe, Denmark
Contact:

Re: Different templates for languages

Post by ZiPs » Thu Jun 25, 2009 8:07 am

Preben Dahl | Webmaster cmsimple.dk | Projekt-og domæne ejer Gert Ebersbach

kweku
Posts: 90
Joined: Sun Jan 18, 2009 3:37 pm

Re: Different templates for languages

Post by kweku » Thu Jun 25, 2009 3:20 pm

Zips,

at the moment i am using this technique which you can see here http://www.insight-design-group.com/imc ... sub-page02
all the sub-pages of vertical inherit the defined liquid and vertical nav template....

but heres the problem. there needs to be an intuitive method of using this technique in the form of a plugin, addon or something that is 'editor' friendly not just for programmers

im willing to pay someone who thinks they are able to produce a simple selector or gadget that allows you the flexibility to assign specific templates to different pages.

one idea that springs to mind, when a user is logged in - you go to 'config' which shows you all the login/password info, meta tags etc...but most importantly there is a drop down of all the installed templates, currently you can select the template you want and then save. What if there was another drop down list menu with all the current pages of the site and somehow you could assign a given template to a specific page or category
there could be a ' assign template to page' button as well as an 'assign template to catgory' button ( which would connect the chosen template to the sub-pages of catgeory )

mvwd
Posts: 299
Joined: Tue Jun 17, 2008 10:35 pm
Location: Baden Württemberg / Germany
Contact:

Re: Different templates for languages

Post by mvwd » Sat Jul 25, 2009 8:26 pm


Post Reply