Elxis CMS Forum

Extensions => Templates => Topic started by: grayarti on October 23, 2008, 21:08:58

Title: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: grayarti on October 23, 2008, 21:08:58
Hi everyone,
I know... everyone has their own personal view of everything, and that is a great thing!
My person view is that a multi-language site would look great if there was a module that
could swap your logo.png according to the language you have chosen with the flag
Language Selector.  This way you could make individual welcome message logo.png files
for your site, one for each individual language you have employed.
I know this can be done on the template, and css files, and have tried to do that, but
with no luck, I really don't know enough!
A Site Module would be a better way I think, which would work together with the Language
Selector module.
Just an idea for you clever programmers out there!  :-*
Gray.
 
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: Ivan Trebješanin on October 23, 2008, 21:27:28
Hello grayarti,

If you examine Elxis features, you can see that it is already possible to do. ;)

HINT:
You can create custom module wich would contain only logo. Then make a copy of this module for each language, and publish it only for the according language.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: ks-net on October 23, 2008, 21:33:47
i think there is no need for a new module  from elxis team...
no specially skills needed for this, you  can do it by yourself just the way you said... with a module.

actually can do it very easy... :

1- put a new module position in template's index file,  beside/next/before/on/ the  logo image or omitted the logo image
(customize your css )
2-add module -position to modules-position page in elxis admin.

3- create-publish-assign one module for each lang put in every module everything you want
images/flashes/text..../slogan-text beside logo/image rotators ... everything

easy?
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: grayarti on October 24, 2008, 09:18:46
Hi guys!
yes, I thought it would be easy enough, and that the possibility was already there. 
I have tried in the past, using lang as a variable, but with no luck. I'll try to learn a
little more about how to create custom modules and template positions, I like this
solution more!
Thanks for your replies.
Gray
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: rentasite on October 24, 2008, 10:08:27

Which template are you using?
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: grayarti on October 24, 2008, 11:31:54
Hello Supernet,
well, I'm still just playing around with Elxis, getting to know as much as I can on a local web-server,
before building sites that I have in mind.  I have tried most downloadable frontend templates, but
always go back to using a modified okto template.
I'm planning on reading through the template tutor .pdf this weekend, and learn as much as I can
about how these template and css files connect, because this is obviously a MUST, to get the most
out of the core Elxis cms.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: rentasite on October 24, 2008, 11:37:14

Ok!

Its all about a module position for your logo.  If the template your going to use, has a module position for your logo to appear... its SO EASY. Or else, read how to create a module position.

Good luck :)
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: CREATIVE Options on October 24, 2008, 16:13:49
I have also to add the option to assign a template to each language.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: grayarti on October 25, 2008, 19:07:54
OK! Done!  :o ... that was so easy!
thanks guys!
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: datahell on October 25, 2008, 22:24:27
If you wish to apply multi-linguism directly in your template it is very easy. the current selected language is stored in the Elxis' global variable $lang ($alang for the administration area). You don't have to create different templates for each language! (Although this is also a solution). Here is a simple way how you can display different things in your template depending on the user selected language:

Code: (php) [Select]
<?php 
if ($lang == &#39;greek&#39;) {
    //display the greek image
    
echo &#39;<img src="images/image1-greek.png" alt="Ελληνική εικόνα" />&#39;;
} elseif ($lang == &#39;english&#39;) {
    //display the english image
    
echo &#39;<img src="images/image1-english.png" alt="English image" />&#39;;
} elseif ($lang == &#39;spanish&#39;) {
    //display the spanish image
    
echo &#39;<img src="images/image1-spanish.png" alt="imagen española" />&#39;;
} else {
    
//display a standard image
    
echo &#39;<img src="images/image1.png" alt="standard image" />&#39;;
}
?>

Notice: if you write non latin1 characters in your template's index.php file then you should save it as utf-8.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: CREATIVE Options on October 25, 2008, 22:42:52
I can assume that we can place also a flash object instead of the image.

I will test it and post the relevant code.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: datahell on October 26, 2008, 00:12:25
The image is just a sample.
It's PHP, you can enter whatever you like, even you can include whole files or a whole CMS!
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: grayarti on October 26, 2008, 11:40:55
Hi again Datahell,
Yes, this is more-or-less the coding I was playing around with trying to get a different logo
for each selected language. (There was an example here already since the 2006 release.)
My question is "Where would you use this php coding? In the index.php file, I would guess?
Right? 
The problems and doubts that I had, were because the logo.jpg is set up in the layout.css file,
and I couldn't seem to be able to understand the connection between these two files enabling
you to be able to do that!    ;D
I tried many times, in different ways, but always ended up with a blank logo!
Now I am using custom modules for each language which works just fine, BUT it would be
interesting to know what I was doing wrong, and could be useful for other things, and informative
to other users.
Thanks,
Gray.
Title: Re: Being a multi-language CMS, wouldn't a multi-language logo bar be useful?
Post by: datahell on October 26, 2008, 13:46:02
No problem even with CSS, I said it's PHP, you can do whatever you like!
Here is a sample how to modify CSS based on user selected language using PHP.

Open your template's index.php file, we will work inside the <head></head> tags of the template and bellow the lines that loads your CSS file(s) in order to be able to overwrite CSS settings.

Here is a sample layout where a background image is being loaded for the div with CSS class "myback":
Code: (html) [Select]
<html>
<head>
......
<link href="..../templates/...../css/template_css.css" rel="stylesheet" type="text/css" media="all" />
..............
==> WE WILL ADD OUT PHP CODE HERE <==
</head>
<body>
<div id="container">
     <div class="myback">.....</div>
</div>
</body>
</html>

Method 1, modifying just a background image with inline css.
We create alternative css settings that will overwrite the one that comes from the template_css.css file if the user has selected an other language.

<style type="text/css">
<?php if ($lang == 'english') { ?>
     .myback {  background: url('templates/mytemplate/images/image-english.png') top left no-repeat; }
<?php } else if ($lang == 'turkish') { ?>
     .myback {  background: url('templates/mytemplate/images/image-turkish.png') top left no-repeat; }
<?php } ?>
</style>

Method 2, modifying just a background image using css classes declared on the template's css.
In our template_css.css file we create language specific classes for the background image:

In template_css.css file (or customize.css file):
.myback-english {  background: url('images/image-english.png') top left no-repeat; }
.myback-greek {  background: url('images/image-greek.png') top left no-repeat; }
.myback-turkish {  background: url('images/image-turkish.png') top left no-repeat; }

In out template's index.php file:

<div class="myback-<?php echo $lang; ?>">.....</div>

Method 3, loading different css files for each language
If we need to do more changes based on the user selected language then it is better to create separate css files based on user selected language.

So, we create template_css_greek.css, template_css_turkish.css, etc.
Now, in index.php file we load the proper css file based on the user's selected language:

<?php if ($lang == 'greek') { ?>
    <link href="..../templates/...../css/template_css_greek.css" rel="stylesheet" type="text/css" media="all" />
<?php } else if ($lang == 'turkish') { ?>
    <link href="..../templates/...../css/template_css_turkish.css" rel="stylesheet" type="text/css" media="all" />
<?php } else { ?>
    <link href="..../templates/...../css/template_css.css" rel="stylesheet" type="text/css" media="all" />
<?php } ?>

Alternative method
And here is a short alternative of the method 3 that checks the css file existence and loads automatically the proper one:
<?php
$cssfile = $mainframe->getCfg('live_site').'/templates/mytemplate/template_css.css';
if (file_exists($mainframe->getCfg('absolute_path').'/templates/mytemplate/template_css_'.$lang.'.css')) {
     $cssfile = $mainframe->getCfg('live_site').'/templates/mytemplate/template_css_'.$lang.'.css';
}
?>
<link href="<?php echo $cssfile; ?>" rel="stylesheet" type="text/css" media="all" />