Tuesday 20 December 2011

language and country selector in header

This post will guide you on how to show country flags selector in header.



Step 1: Make sure multiple language stores are available.
Now open flags.phhml file located at app/design/frontend/default/theme/template/page/switch/flags.html
If in case it does not exists then create it and replace existing code/ add following code into file.
Note: Please modify href & src in following code.

  1.  < ?php if(count($this->getGroups())>1): ?>  
  2. <div id="countrySelector" class="w940 mT10">  
  3. <ul>  
  4.     < ?php foreach ($this->getGroups() as $_group): ?>  
  5. <li>  
  6.           <a alt="<?php echo $this->htmlEscape($_group->getName()) ?>" hre="" f="< ?php echo $_group->getHomeUrl(); ?>">  
  7.           <img sr="" c="<?php echo $this-/>getSkinUrl('images/flag' . $this->htmlEscape($_group->getName()) . '.png') ?>" alt="< ?php echo $this->htmlEscape($_group->getName()) ?>" height="18" width="26">  
  8.           </a>  
  9.         </li>  
  10.   
  11.     < ?php endforeach; ?>  
  12.      </ul>  
  13. </div>  
  14.   
  15. < ?php endif; ?>  
Step 2: Now add entry into page.xml file and file header block i.e. “html_header”.
In case if you want to add flags in footer section then search for footer block and add following line in footer and do little css to align it correctly.

Step 3: Upload flag images into “skin/frontend/currentTheme/images/” directory and make sure the flag file names are having store name is part of flag name.
(i.e. Image name is “flagEnglish.gif”, “flagGerman.gif”. So store names are “English”, “German”, etc)
Now clean the magento cache and reload the home page and you are done!!.
In case if you are not able to see the flags then let me know, i would love to help you.

No comments:

Post a Comment