Page 1 of 1
Currency/language switcher - displaying all flags in header
Posted: Tue Aug 31, 2010 3:38 am
by fireatwire
Hi,
I want to change the way the currency and language switcher works in my layout.
Has somebody tried to arrange it that way, that you only see the flag-icons, and they are listed side by side on the header template?
Appreciate your help!
Re: Currency/language switcher - displaying all flags in hea
Posted: Tue Aug 31, 2010 9:48 am
by JAY6390
Just tried this now. It's amazingly easy to do
Open
/catalog/controller/common/header.php
after
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
$this->session->data['language'] = $this->request->post['language_code'];
if (isset($this->request->post['redirect'])) {
$this->redirect($this->request->post['redirect']);
} else {
$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
}
}
put this code
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'GET') && isset($this->request->get['language_code'])) {
$this->session->data['language'] = $this->request->get['language_code'];
if (isset($this->request->get['redirect'])) {
$this->redirect($this->request->get['redirect']);
} else {
$this->redirect(HTTP_SERVER . 'index.php?route=common/home');
}
}
Then in /catalog/view/theme/default/template/common/header.tpl find and delete this code
Code: Select all
<form action="<?php echo str_replace('&', '&', $action); ?>" method="post" enctype="multipart/form-data" id="language_form">
<div class="switcher">
<?php foreach ($languages as $language) { ?>
<?php if ($language['code'] == $language_code) { ?>
<div class="selected"><a><img src="image/flags/<?php echo $language['image']; ?>" alt="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a></div>
<?php } ?>
<?php } ?>
<div class="option">
<?php foreach ($languages as $language) { ?>
<a onclick="$('input[name=\'language_code\']').attr('value', '<?php echo $language['code']; ?>'); $('#language_form').submit();"><img src="image/flags/<?php echo $language['image']; ?>" alt="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
<?php } ?>
</div>
</div>
<div>
<input type="hidden" name="language_code" value="" />
<input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
</div>
</form>
in it's place put
Code: Select all
<?php foreach($languages as $language) : ?>
<a href="<?php echo str_replace('&', '&', $action); ?>&redirect=<?php echo urlencode($redirect); ?>&language_code=<?php echo urlencode($language['code']); ?>"><img src="image/flags/<?php echo $language['image']; ?>" alt="<?php echo $language['name']; ?>" /></a>
<?php endforeach; ?>
and its done
Re: Currency/language switcher - displaying all flags in hea
Posted: Wed Sep 01, 2010 5:33 pm
by fireatwire
+++
thank you! it works perfectly.
(but it's header.php not home.php)
Re: Currency/language switcher - displaying all flags in hea
Posted: Wed Sep 01, 2010 6:52 pm
by JAY6390
Hi, yes sorry I meant header not home. It was 3am at the time, clearly I should have gone to bed
Re: Currency/language switcher - displaying all flags in hea
Posted: Tue Sep 14, 2010 3:59 pm
by fireatwire
When I click on a flag to switch the language I get this error:
Warning: Cannot modify header information - headers already sent by (output started at /catalog/model/catalog/category.php:25) in /system/engine/controller.php on line 27
Do you know what I need to do to get it working again?
Re: Currency/language switcher - displaying all flags in hea
Posted: Tue Sep 14, 2010 11:58 pm
by celestial
And the currency???