Language depending templates

Please post the URLs to pages, where you've made a CMSimple template available for download

Moderator: mikey

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

Language depending templates

Post by Tata » Fri Oct 07, 2016 6:39 am

With old version of CMSimple I used language depending templates with:

Code: Select all

<?php
if($sl=='sk') $cf['site']['template']="template";
if($sl=='de') $cf['site']['template']="template_de"; 
if($sl=='en') $cf['site']['template']="template_en";
?>
in each template.
It was becasue of some parts in main template were left off in another languages.
So I had:
[templates]
stylesheet.css
template.htm
/[template_de]
stylesheet.css
template.htm
/[template_en]
stylesheet.css
template.htm
Now this trick doesn't work. The language contents are loaded, but only into the basic template defined in config.sys. How to make it? I want - switching to DE or EN open the page with another tamplate. I know, I can use template definition on each language page, but this seems to be possible easier.
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.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Language depending templates

Post by cmb » Fri Oct 07, 2016 8:20 am

Tata wrote:With old version of CMSimple I used language depending templates with:

Code: Select all

<?php
if($sl=='sk') $cf['site']['template']="template";
if($sl=='de') $cf['site']['template']="template_de"; 
if($sl=='en') $cf['site']['template']="template_en";
?>
in each template.
The code is supposed to work, but not when inserted into template.htm, but rather in userfuncs.php, for example.
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: Language depending templates

Post by Tata » Fri Oct 07, 2016 9:25 am

Aha, I'll try it. In the old versions it must have been on the template beginning.
Thanks.
Last edited by Tata on Fri Oct 07, 2016 11:28 am, edited 1 time in total.
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.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Language depending templates

Post by cmb » Fri Oct 07, 2016 11:17 am

Tata wrote:Doesn't work.
You're right. You also have to reset the template paths like so:

Code: Select all

<?php
if($sl=='sk') $cf['site']['template']="template";
if($sl=='de') $cf['site']['template']="template_de"; 
if($sl=='en') $cf['site']['template']="template_en";

$_XH_controller->initTemplatePaths();
However, you can alternatively set $tx['subsite']['template'] what must be done in the language file(s) directly.
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: Language depending templates

Post by Tata » Fri Oct 07, 2016 11:28 am

Doesn't work. Only the language files are loaded to the same basic template.
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.

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Language depending templates

Post by lck » Fri Oct 07, 2016 4:45 pm

For me, it works. Just a ?> had to be added.
Paste code on the beginning of template.htm, before <!DOCTYPE html>

Code: Select all

<?php
if($sl=='sk') $cf['site']['template']="template";
if($sl=='de') $cf['site']['template']="template_de"; 
if($sl=='en') $cf['site']['template']="template_en";

$_XH_controller->initTemplatePaths();
?>
<!DOCTYPE html>
...
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

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

Re: Language depending templates

Post by Tata » Fri Oct 07, 2016 5:21 pm

For me it doesn't work. Even uploading to the server the slideshow is reduced to an empty line. Tried to add dimension in stylesheets of the template and slideshow plugin - without result.
Have a look at http://ukastelana.cmsimple.sk
I just hope the OPcache is not involved again :-(
I just can't understand that ot works fine on localhost but not on server.
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.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Language depending templates

Post by cmb » Fri Oct 07, 2016 6:15 pm

lck wrote:Paste code on the beginning of template.htm, before <!DOCTYPE html>
That is not supposed to work. :? Switching the template has to be done before template.htm is included.
Tata wrote:I just hope the OPcache is not involved again :-(
I just can't understand that ot works fine on localhost but not on server.
I'm pretty sure it is a caching issue again.
Christoph M. Becker – Plugins for CMSimple_XH

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Language depending templates

Post by lck » Fri Oct 07, 2016 6:33 pm

Seems to work, see view-source:http://ukastelana.cmsimple.sk/de/

Code: Select all

<link rel="stylesheet" href="../templates/ukastelana-de/stylesheet.css" type="text/css">
and view-source: http://ukastelana.cmsimple.sk/en/

Code: Select all

<link rel="stylesheet" href="../templates/ukastelana-en/stylesheet.css" type="text/css">
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: Language depending templates

Post by lck » Fri Oct 07, 2016 6:52 pm

@Tata: Du hast einige Fehler im Code

1.) Löschen in template/stylesheet.css (ist zuviel des Guten), entweder im Plugin-css angeben oder in der template-css
.content div.slideshow {
...
}

2.) Klassenname slideshow doppelt vorhanden (Auszug Quelltext) - class slideshow wird schon durch das Plugin erzeugt!
<div class="slideshow"><div id="slideshow_1" class="slideshow" ...

Im Pluginaufruf ändern, z.B.:
<div class="slideshow_xh">{{{slideshow('...');}}}</div>
auch css ändern (evtl. auch ein height hinzu)

3.) background url falsch, Bindezeichen statt Unterstrich: kastelan-bg.jpg ändern zu kastelan_bg.jpg

Die Browser-Console bringt auch einen Fehler:
webkitRequestAnimationFrame' is vendor-specific. Please use the standard 'requestAnimationFrame' instead. .................................. Please use the standard 'requestAnimationFrame' instead.
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

Post Reply