Page 1 of 1

Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 8:27 am
by Tata
I run one older webpage and have prepared reduced template for viewing on mobiles. There is a link in the template prepared to switch the "mobile mode". But how to tell the link to open the page with the second template?
Adding #cmsimple $cf['site']['template']="kastelan";# does not help. The page is still open with the default template.

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 9:29 am
by mikey
i try when i can, and even this may be not what you mean, however, in template.htm ( in the code for the opened page )

Code: Select all

<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "http://abcd.com";
}
//-->

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 9:45 am
by Tata
Well, it's really not exactly what I need, but it is interesting too.
With newer versions of CMSimple_XH it's very simple. But the webpage was built and still runs unupgraded. ANd there shall be the config variable re-defined for this only subpage.
Have a look at http://ukastelana.eu. There is daily menu in the right column and I want to have it show on mobile as the only page. In the second template everything but this section is removed. I want a button/link to this only page to be used on mobiles e.g. http://ukastelana.eu/?mobile

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 10:13 am
by cmb
Tata wrote:There is a link in the template prepared to switch the "mobile mode". But how to tell the link to open the page with the second template?
Basically, you need some PHP code on the server that changes the template, some URL parameter which triggers this code, and maybe additionally a cookie so the mobile template stays after navigation. Handheld_XH offers these features, but it might not work with classic CMSimple.

The code to change the template ideally goes to cmsimple/userfuncs.php, but this is not possible for classic CMSimple, so put it into cmsimple/functions.php:

Code: Select all

if (isset($_GET['mobile_version']) && $_GET['mobile_version']) {
    $cf['site']['template'] = 'NAME_OF_THE_TEMPLATE'; // customize!
    $pth['folder']['template'] = $pth['folder']['templates']
        . $cf['site']['template'] . '/';
    $pth['file']['template'] = $pth['folder']['template'] . 'template.htm';
    $pth['file']['stylesheet'] = $pth['folder']['template'] . 'stylesheet.css';
    $pth['folder']['menubuttons'] = $pth['folder']['template'] . 'menu/';
    $pth['folder']['templateimages'] = $pth['folder']['template'] . 'images/';
}
Then you can request (or link to) http://ukastelana.eu/?&mobile_version=1.

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 12:20 pm
by Tata
Ja, super, die Seite is am CMSimple 3.2. Und mit functions.php auch läuft es. Nur mit Charset kann ich da nicht zurecht kommen. Egal ob charset im Template definiert ist.

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 1:20 pm
by cmb
Tata wrote:Nur mit Charset kann ich da nicht zurecht kommen. Egal ob charset im Template definiert ist.
Der charset sollte am besten immer vom Server per Content-Type header angegeben werden (die Angabe im HTML ist nur eine Notlösung). Wie man das bei NGinX einstellt, weiß ich nicht. Du kannst es aber auch per PHP machen:

Code: Select all

header('Content-Type: text/html; charset=windows-1250', true); 
Diese Zeile am besten in cmsimple/cms.php einfügen, und zwar direkt bevor das Template eingelesen wird (include($pth['file']['template'])).

Insgesamt ist es aber vermutlich das Beste, wenn Du die Site bei Gelegenheit mal auf CMSimple_XH 1.6.x aktualisierst.

Re: Load a webpage via a link with another template.

Posted: Thu Jul 02, 2015 1:37 pm
by Tata
Ich habe es schon auch local versucht, die Seite ist aber so komplex, dass ich werde es ambesten tief testen müssen, ob es alles stimmt. Dan brauche ich auch nichts lösen, weil es durch Page Reiter ganz eifach geht.
Vielen Dank.
Es haben endlich die Ferien begonnen, so werde ich wohl mehr Zeit für CMSimple_XH haben.