Page 1 of 2

Language depending templates

Posted: Fri Oct 07, 2016 6:39 am
by Tata
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.

Re: Language depending templates

Posted: Fri Oct 07, 2016 8:20 am
by cmb
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.

Re: Language depending templates

Posted: Fri Oct 07, 2016 9:25 am
by Tata
Aha, I'll try it. In the old versions it must have been on the template beginning.
Thanks.

Re: Language depending templates

Posted: Fri Oct 07, 2016 11:17 am
by cmb
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.

Re: Language depending templates

Posted: Fri Oct 07, 2016 11:28 am
by Tata
Doesn't work. Only the language files are loaded to the same basic template.

Re: Language depending templates

Posted: Fri Oct 07, 2016 4:45 pm
by lck
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>
...

Re: Language depending templates

Posted: Fri Oct 07, 2016 5:21 pm
by Tata
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.

Re: Language depending templates

Posted: Fri Oct 07, 2016 6:15 pm
by cmb
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.

Re: Language depending templates

Posted: Fri Oct 07, 2016 6:33 pm
by lck
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">

Re: Language depending templates

Posted: Fri Oct 07, 2016 6:52 pm
by lck
@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.