Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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>
- Login | My Cart | Compare | Wish List | LANGUAGE
- <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
- <?xml version="1.0"?>
- <config>
- <modules>
- <Easylife_Locale>
- <codePool>local</codePool>
- <active>true</active>
- <depends>
- <Mage_Core />
- </depends>
- </Easylife_Locale>
- </modules>
- </config>
- <?xml version="1.0"?>
- <config>
- <modules>
- <Easylife_Locale>
- <version>1.0.0</version>
- </Easylife_Locale>
- </modules>
- <global>
- <blocks>
- <easylife_locale>
- <class>Easylife_Locale_Block</class>
- </easylife_locale>
- </blocks>
- </global>
- <frontend>
- <layout>
- <updates>
- <easylife_locale>
- <file>easylife_locale.xml</file>
- </easylife_locale>
- </updates>
- </layout>
- </frontend>
- </config>
- <?xml version="1.0"?>
- <layout>
- <default>
- <reference name="top.links">
- <block type="easylife_locale/stores" name="stores_links">
- <action method="addStoreLinks"></action>
- </block>
- </reference>
- </default>
- </layout>
- <?php
- class Easylife_Locale_Block_Stores extends Mage_Page_Block_Switch {
- public function addStoreLinks() {
- $parentBlock = $this->getParentBlock();
- if ($parentBlock) {
- $position = 200; //start position
- foreach ($this->getStores() as $store) {
- $params = null;
- if ($store->getId() == $this->getCurrentStoreId()) {
- $params = 'class="current-store"';
- //if you want to skip the current store view just uncomment the next line
- //continue;
- }
- //Print the language code (en, fr)
- $text = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
- //if your want to display the store name comment the line above and uncomment the one below
- //$text = $store->getName();
- $title = $store->getName();
- $parentBlock->addLink($text, $store->getCurrentUrl(), $title, false, array(), $position, null, $params);
- $position += 10;
- }
- }
- return $this;
- }
- }
- <block type="page/switch" template="your_phtml" />
- <default>
- <reference name="header">
- <action method="unsetChild"><name>store_language</name></action> <!--not name, is in fact alias -->
- <reference name="top.links">
- <action method="insert"><blockName>store_language</blockName></action> <!-- block name -->
- </reference>
- </reference>
- </default>
- /* in page/template/links.phtml */
- echo $this->getChildHtml('store_language');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement