I'm looking for a way to add the language switcher to my top links menu. My store has 2 languages and I've modified the languages.phtml file to show the alternate language.
Example: if you are on the English site, then the language switcher will show French as a clickable option to bring you to that store view.
I know that in order to add options to the top links menu, you need to modify the customer.xml file. I know how to add alternate links as I've read plenty of "how to's" however none cover how to add the language bar.
Here is the modifications to
languages.phtml
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<ul>
<?php foreach ($this->getStores() as $_lang): ?>
<?php if($_lang->getId() != $this->getCurrentStoreId()): ?>
<li><a href="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo $_selected; ?>><?php echo $this->htmlEscape($_lang->getName()) ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
The end result should be:
Login | My Cart | Compare | Wish List | LANGUAGE
How can I add the language bar to the top links menu items?
UPDATE
I've tried adding the following to the customer.xml file under :
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
Nothing appears.
Best Answer
Create your extension with it's own layout file and block that adds links to the top menu.
Let's call that
Easylife_Locale
. You will need the following files:app/etc/modules/Easylife_Locale.xml
- the declaration fileapp/code/local/Easylife/Locale/etc/config.xml
- the configuration fileapp/design/frontend/base/default/layout/easylife_locale.xml
- the frontend layout fileapp/code/local/Easylife/Locale/Block/Stores.php
- the block that adds the links to the top.Clear the cache and try it out.