Elxis CMS Forum
Support => General => Topic started by: ROUBOS on March 18, 2012, 17:49:38
-
Hi,
what's the php code we use when we want to check the language before we display some html code? For example display an image if Greek language is selected, and a different image when the English language is selected???
thanks
-
Hi,
In case that you want to write this piece of code inside a function you must call the global variable $lang first. In any other case such a index.php file of your template you can use the variable without call it.
global $lang;
if ($lang == 'greek') {
echo '<img src="gr_image_path.filetype" alt="Image Description in Greek" width="80" height="80" />'."\n";
} elseif ($lang == 'english') {
echo '<img src="en_image_path.filetype" alt="Image Description in English" width="80" height="80" />'."\n";
}
-
Did not work. This is how I used it in my template's index.php:
<div id="banner-right">
if ($lang == 'Greek') {
echo '<a href="http://www.aslanisvillage.com/aitema-krateses.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request_gr.png" alt="Αίτημα Κράτησης" border="0" /></a>'."\n";
} elseif ($lang == 'English') {
echo '<a href="http://www.aslanisvillage.com/reservation-request.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request.png" alt="Reservation Request" border="0" /></a>'."\n";
}
</div>
-
You must open and close php ;)
<div id="banner-right">
<?php
if ($lang == 'greek') {
echo '<a href="http://www.aslanisvillage.com/aitema-krateses.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request_gr.png" alt="Αίτημα Κράτησης" border="0" /></a>'."\n";
} elseif ($lang == 'english') {
echo '<a href="http://www.aslanisvillage.com/reservation-request.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request.png" alt="Reservation Request" border="0" /></a>'."\n";
}
?>
</div>
-
hahaha why didn't I think of that?
Thanks a lot.
-
OK, what am I doing wrong, it's not showing anything now .
<div id="banner-right">
<?php
if ($lang == 'Greek') {
echo '<a href="http://www.aslanisvillage.com/aitema-krateses.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request_gr.png" alt="Αίτημα Κράτησης" border="0" /></a>'."\n";
} elseif ($lang == 'English') {
echo '<a href="http://www.aslanisvillage.com/reservation-request.html"><img class="calendar-img" src="http://www.aslanisvillage.com/templates/aslanisvillage-template/images/reservation_request.png" alt="Reservation Request" border="0" /></a>'."\n";
}
?>
</div>
-
Problem was that Greek and English had to be entered in lower case greek, and english
-
Yes. It was my fault. ;) I corrected them.