Language driven templates

Questions about how to install and problems installing - please read the documentation first!
Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Language driven templates

Post by Tata » Wed Feb 02, 2011 8:11 pm

Please, don't lol. But I somehow can't find what am I doing wrong. There is a CMSimple?XH1.4 installation which I want run both in SK, DE and EN languages. As the content of EN and DE needs different templates. I have created in [templates] folders [mytemplate_sk], [mytemplate_en] and [mytemplate_de]. There is the mytemplate_sk defined as the site-template by default. In each template.htm I put

Code: Select all

<?php 
if($sl=='sk') $cf['site']['template']="mytemplate_sk";
if($sl=='de') $cf['site']['template']="mytemplate_de"; 
if($sl=='en') $cf['site']['template']="mytemplate_en";
?>
But when switching the language always only the default template is loaded.
I know that I can define new template for any page. But to make it for each particular EN or DE page is sure not the right way.
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.

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Language driven templates

Post by Gert » Wed Feb 02, 2011 8:45 pm

Hi Tata,

I have a CMSimple_XH Solution ready, based on CMSimple_XH 1.4.

With that you can give every language an own template and an own password, if you want. If nothing is set, the default template and password are in use.

And you can operate subsites so much as you want, with one CMSimple_XH-installation. Every subsite also can have an own template and an own password, if you want. If nothing is set, the default template and password are in use.

You will find a folder "2site" (like "2lang"), copy it and rename it to "anything", copy a language-file of your choice and rename it to "anything.php", do the same with a language-config-file of your choice ("anythingconfig.php") - ready, you can call the subsite by calling the folder "anything", login and set template and password by langconfig settings.

You can also create a pluginloader-language-file "anything.php", but you not have to do that, if that file not exists, the pluginloader works in English.

Do you want to test it?
Gert Ebersbach | CMSimple | Templates - Plugins - Services

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

Re: Language driven templates

Post by Tata » Wed Feb 02, 2011 8:53 pm

Of course I want. You know I have a plenty of time right now.
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.

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Language driven templates

Post by Gert » Wed Feb 02, 2011 8:59 pm

Download: http://www.ge-webdesign.de/cmsimple/dlc ... php?id=301

Every interested user may download and test it. I'm curious, if that is interesting for anyone ;)

I remember, that the question of different templates for every language is not new. The subsite-Solution is just a nice additional option.
Gert Ebersbach | CMSimple | Templates - Plugins - Services

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: Language driven templates

Post by Martin » Fri Feb 04, 2011 11:11 am

O, I missed a hot discussion triggered by Gert's subsites-solution.

But to come back to the question of localized templates. No need for fiddeling around with the configuration or even changing the core files. IMHO the "template.htm" itself is the best place for conditional layouts. Here you can just include whatever you need, different template blocks or completely different templates. E.g. you could just create your localized templates and come up with this folder structure:
  • my_template
    • en_template.htm
    • sk_template.htm
    • de_template.htm
    • template.htm
Your real templates are in the "sl_template.htm"-files. In this simple case, your "template.htm" just needs one single line:

Code: Select all

<?php include $sl . '_template.htm'; ?>
But of course you could also keep your basic template in the "template.htm" and just include those sections that need localization. (This approach, using the "template.htm" as a switch, is very flexible: You can offer different templates - 2 or three columns - for pages with / without subnavigation, for the start page, top-level-pages, in the daytime / in the night etc. )

Martin

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Language driven templates

Post by Holger » Fri Feb 04, 2011 12:33 pm

Martin wrote:IMHO the "template.htm" itself is the best place for conditional layouts.
Yep, as I wrote in the other thread, with a basic php knowlwdge, it's not a real problem.

Holger

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Language driven templates

Post by Gert » Fri Feb 04, 2011 12:48 pm

Holger wrote:Yep, as I wrote in the other thread, with a basic php knowlwdge, it's not a real problem.
But in a usable CMS every user should can do that without such knowledge, by dialog in the settings.

In another thread you wrote: "I like dialogues" - and now you like necessary php knowledge and scripting for the users?

The subsite solution is a solution to operate several Websites in subfolders with just one installation of CMSimple_XH and Plugins in the Root. To give a language another template without php knowledge is just one little aspect of the subsite solution, done by the way.

The user can use it or do it by another way - no problem ;)
Gert Ebersbach | CMSimple | Templates - Plugins - Services

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Language driven templates

Post by Holger » Fri Feb 04, 2011 1:34 pm

Gert wrote:But in a usable CMS every user should can do that without such knowledge, by dialog in the settings.

In another thread you wrote: "I like dialogues" - and now you like necessary php knowledge and scripting for the users?
No, that's why I've posted that small change to cms.php:

Code: Select all

if ($sl != $cf['language']['default'] && is_dir($pth['folder']['template'].basename($sl).'/')) {
    $pth['folder']['template'] .= basename($sl).'/';
}  
With that, a user only have to create a subfolder. No need to know about programming in template.htm or anywhere else.
And no dialog or other config etc needed ;)

Holger

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: Language driven templates

Post by Holger » Fri Feb 04, 2011 1:39 pm

Gert wrote:The subsite solution is a solution to operate several Websites in subfolders with just one installation of CMSimple_XH and Plugins in the Root. To give a language another template without php knowledge is just one little aspect of the subsite solution, done by the way.

The user can use it or do it by another way - no problem ;)
It seems to be a problem if someone posts another solution :? :(

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: Language driven templates

Post by Gert » Fri Feb 04, 2011 3:37 pm

Holger wrote:It seems to be a problem if someone posts another solution :? :(
You don't want to understand.

Subsite solution is NOT a solution to give another language another template. That's just a small additional feature of subsite solution. I know that there are many other solutions for that.

And now I will quit the discuss about localized templates.
Gert Ebersbach | CMSimple | Templates - Plugins - Services

Post Reply