CMSimple_XH_153 templates for different languages

Questions about how to install and problems installing - please read the documentation first!
Eddy
Posts: 37
Joined: Wed Oct 19, 2011 1:42 am

CMSimple_XH_153 templates for different languages

Post by Eddy » Wed Mar 28, 2012 12:04 pm

Hi everybody,

I would like to use different templates for different languages with CMSimple_XH_153 for the following reason.
I managed to give every header and sub-header a different "top"-image by inserting the following code before the <head> function:

<?php
// echo $su;
switch($su)
{
// H1 headings.
case "Willkommen": $img_top = $pth['folder']['templateimages']."willkommen.jpg"; break;
.
.
case "Dienstleistungen": $img_top = $pth['folder']['templateimages']."dienstleistungen.jpg"; break;
.
.
// H2 headings.
case "Dienstleistungen:Marketing": $img_top = $pth['folder']['templateimages']."Marketing.jpg"; break;

// If no pagetitle ($su) did match, show default top image.
default: $img_top = $pth['folder']['templateimages']."willkommen.jpg";
}
?>

This is working wonderfully except for I can't get it to work in the English language installation.

What I have done till now is:
1. Create a new template called en_template where I adjusted the code before mentioned into English (e.g Willkommen to Welcome, etc.)
2. Then I created a copy of the default cms and called it en_cms and changed the line where the file (template) is called to en_template.
3. In the folder "en" for the second language I changed the index.php to call en_cms.php

Well, needless to say this solution doesn't work, I get "access denied" on my test server (XAMP) when trying to access the English page after doing step 3. like above mentioned.

How can I keep using the different "tops" / headers for the different menus and sub-menus in the other languages as well?

Thanks for your help!

cmb
Posts: 13341
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple_XH_153 templates for different languages

Post by cmb » Wed Mar 28, 2012 12:15 pm

Hi Eddy,

basically your first attempt is ok. You only have to add a second level of check for $sl:

Code: Select all

<?php
switch ($sl)
{
case 'de':
    // echo $su;
    switch($su)
    {
    // H1 headings. 
    case "Willkommen": $img_top = $pth['folder']['templateimages']."willkommen.jpg"; break;
    .
    .
    case "Dienstleistungen": $img_top = $pth['folder']['templateimages']."dienstleistungen.jpg"; break; 
    .
    . 
    // H2 headings.
    case "Dienstleistungen:Marketing": $img_top = $pth['folder']['templateimages']."Marketing.jpg"; break;
  
    // If no pagetitle ($su) did match, show default top image.
   default: $img_top = $pth['folder']['templateimages']."willkommen.jpg";
   break;
case 'en':
  // here the same for the englisch pages
  break;
}
 
But for easier maintaince you can set the global $img_top on every single CMSimple page too:

Code: Select all

#CMSimple $img_top = 'willkommen.jpg';#
And in the template:

Code: Select all

if (isset($img_top)) { // use image that's set by CMSimple scripting
    $img_top = $pth['folder']['templateimages'].$img_top;
} else { // default image
    $img_top = $pth['folder']['templateimages']."willkommen.jpg";
}
 
Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Eddy
Posts: 37
Joined: Wed Oct 19, 2011 1:42 am

Re: CMSimple_XH_153 templates for different languages

Post by Eddy » Wed Mar 28, 2012 1:28 pm

Hi Christoph,

Thanks for your fast answer. I tried your first option and got a completely blank page. Undid that and would like to try your second solution, but either I'm too tired (been on it since last night:)) or my conception of coding ain't the best.

Would you mind posting a "step by step" of how and where to insert the code? That would be fantastic. Thanks again!

cmb
Posts: 13341
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple_XH_153 templates for different languages

Post by cmb » Wed Mar 28, 2012 2:04 pm

Hi Eddy,

you only need 1 template for this solution (not seperate ones for different languages). Just replace the old switch code in the template (the complete <?php ... ?>) with:

Code: Select all

<?php
if (isset($img_top)) { // use image that's set by CMSimple scripting
    $img_top = $pth['folder']['templateimages'].$img_top;
} else { // default image
    switch ($sl) { // I had forgotten this switch in the former post
        case 'en': $img_top = $pth['folder']['templateimages']."welcome.jpg"; break;
        default: $img_top = $pth['folder']['templateimages']."willkommen.jpg"; break;
    }
}
?>
This should show the default image always (I've not tested it, though).

On every CMSimple page you want another header image, you have to insert in the content:

Code: Select all

#CMSimple $img_top = 'willkommen.jpg';#
Replace willkommen.jpg with the path to your image relative to the templateimages folder. I.e.: if the image is directly in this folder, just use the name of the file.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Eddy
Posts: 37
Joined: Wed Oct 19, 2011 1:42 am

Re: CMSimple_XH_153 templates for different languages

Post by Eddy » Wed Mar 28, 2012 2:37 pm

Hi Christoph,

First of all, thanks again for your help.

I changed the first part of the code in the template as suggested.
Then as I was logged in, I went to the "Welcome" Menu on the English site and pasted the second code. My results are/show as following examples on the page and don't show the according "top":

#CMSimple $img_top = 'willkommen.jpg';#
Welcome

Discover the fascinating ....

or

Welcome

Discover the fascinating ...
.
.
.
#CMSimple $img_top = 'willkommen.jpg';#

depending on where I insert the code.

I think I might be doing something really easy really wrong, but I can't come up with it.

Thanks

cmb
Posts: 13341
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple_XH_153 templates for different languages

Post by cmb » Wed Mar 28, 2012 2:46 pm

Hi Eddy,
Eddy wrote:My results are/show as following examples on the page and don't show the according "top":
You have to insert all CMSimple scripts in the HTML source code mode. Otherwise the editor might replace single characters with HTML-entities, and it won't work.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Eddy
Posts: 37
Joined: Wed Oct 19, 2011 1:42 am

Re: CMSimple_XH_153 templates for different languages

Post by Eddy » Wed Mar 28, 2012 2:57 pm

Hi Christoph,

Hmm... I've been doing that. When I instert your second code into the page I go to the HTML button and another window opens with the page in "code form". That's where I insert the code and then click on the update button on the bottom... Still, won't work, sorry.. any suggestions?

Thank you

cmb
Posts: 13341
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple_XH_153 templates for different languages

Post by cmb » Wed Mar 28, 2012 3:03 pm

Hi Eddy,

have you switched to view mode? The script will be shown as is in edit mode.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Eddy
Posts: 37
Joined: Wed Oct 19, 2011 1:42 am

Re: CMSimple_XH_153 templates for different languages

Post by Eddy » Wed Mar 28, 2012 3:12 pm

Hi Christoph,

I'm using the CMSimple_XH_153 version. The only buttons I can find related to this are:

1. Save
2. Toggle Full Screen Mode
3. HTML (Edit HTML source)

That's why I click on HTML and edit it there to finally press on the update button of that separate window to get back to the normal view (because it closes itself then) to then save it.
Where do I insert your second code exactly? I've been trying to set it before the <h1> function, but it will not take it and kick it out during the "update"-process. If I set it elsewhere, it will take it as a normal other text and show it that way...

Thanks again.

cmb
Posts: 13341
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: CMSimple_XH_153 templates for different languages

Post by cmb » Wed Mar 28, 2012 3:16 pm

Hi Eddy,

I guess you've done everything correctly (#CMSimple ...# has to go below the heading; typically it doesn't matter were you put it on the page). But if you want to see it being evaluated (i.e. working), you have to click "view mode" on the left hand side of the admin menu (the dark bar on top of the screen, above the page).

Christoph

PS:
Eddy wrote:but it will not take it and kick it out during the "update"-process.
I'm not sure, if it didn't end up on the page before the one you're editing. So you better check that.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply