Load a webpage via a link with another template.

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

Load a webpage via a link with another template.

Post by Tata » Thu Jul 02, 2015 8:27 am

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.
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.

mikey
Site Admin
Posts: 179
Joined: Tue May 27, 2008 3:15 am
Location: Sydney Australia

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

Post by mikey » Thu Jul 02, 2015 9:29 am

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";
}
//-->

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

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

Post by Tata » Thu Jul 02, 2015 9:45 am

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
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: Load a webpage via a link with another template.

Post by cmb » Thu Jul 02, 2015 10:13 am

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.
Christoph M. Becker – Plugins for CMSimple_XH

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

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

Post by Tata » Thu Jul 02, 2015 12:20 pm

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.
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: Load a webpage via a link with another template.

Post by cmb » Thu Jul 02, 2015 1:20 pm

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.
Christoph M. Becker – Plugins for CMSimple_XH

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

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

Post by Tata » Thu Jul 02, 2015 1:37 pm

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.
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.

Post Reply