Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. <?php if(count($this->getStores())>1): ?>
  2. <div class="form-language">
  3. <ul>
  4. <?php foreach ($this->getStores() as $_lang): ?>
  5. <?php if($_lang->getId() != $this->getCurrentStoreId()): ?>
  6. <li><a href="<?php echo $_lang->getCurrentUrl(false) ?>"<?php echo $_selected; ?>><?php echo $this->htmlEscape($_lang->getName()) ?></a></li>
  7. <?php endif; ?>
  8. <?php endforeach; ?>
  9. </ul>
  10.  
  11. Login | My Cart | Compare | Wish List | LANGUAGE
  12.  
  13. <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
  14.  
  15. <?xml version="1.0"?>
  16. <config>
  17. <modules>
  18. <Easylife_Locale>
  19. <codePool>local</codePool>
  20. <active>true</active>
  21. <depends>
  22. <Mage_Core />
  23. </depends>
  24. </Easylife_Locale>
  25. </modules>
  26. </config>
  27.  
  28. <?xml version="1.0"?>
  29. <config>
  30. <modules>
  31. <Easylife_Locale>
  32. <version>1.0.0</version>
  33. </Easylife_Locale>
  34. </modules>
  35. <global>
  36. <blocks>
  37. <easylife_locale>
  38. <class>Easylife_Locale_Block</class>
  39. </easylife_locale>
  40. </blocks>
  41. </global>
  42. <frontend>
  43. <layout>
  44. <updates>
  45. <easylife_locale>
  46. <file>easylife_locale.xml</file>
  47. </easylife_locale>
  48. </updates>
  49. </layout>
  50. </frontend>
  51. </config>
  52.  
  53. <?xml version="1.0"?>
  54. <layout>
  55. <default>
  56. <reference name="top.links">
  57. <block type="easylife_locale/stores" name="stores_links">
  58. <action method="addStoreLinks"></action>
  59. </block>
  60. </reference>
  61. </default>
  62. </layout>
  63.  
  64. <?php
  65.  
  66. class Easylife_Locale_Block_Stores extends Mage_Page_Block_Switch {
  67. public function addStoreLinks() {
  68. $parentBlock = $this->getParentBlock();
  69. if ($parentBlock) {
  70. $position = 200; //start position
  71. foreach ($this->getStores() as $store) {
  72. $params = null;
  73. if ($store->getId() == $this->getCurrentStoreId()) {
  74. $params = 'class="current-store"';
  75. //if you want to skip the current store view just uncomment the next line
  76. //continue;
  77. }
  78. //Print the language code (en, fr)
  79. $text = substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
  80. //if your want to display the store name comment the line above and uncomment the one below
  81. //$text = $store->getName();
  82. $title = $store->getName();
  83.  
  84. $parentBlock->addLink($text, $store->getCurrentUrl(), $title, false, array(), $position, null, $params);
  85. $position += 10;
  86. }
  87. }
  88. return $this;
  89. }
  90. }
  91.  
  92. <block type="page/switch" template="your_phtml" />
  93.  
  94. <default>
  95. <reference name="header">
  96. <action method="unsetChild"><name>store_language</name></action> <!--not name, is in fact alias -->
  97. <reference name="top.links">
  98. <action method="insert"><blockName>store_language</blockName></action> <!-- block name -->
  99. </reference>
  100. </reference>
  101. </default>
  102.  
  103. /* in page/template/links.phtml */
  104. echo $this->getChildHtml('store_language');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement