简体   繁体   中英

Magento how to display country flag in currency drop down?

I am trying to add all country flag in currency change dropdown in magento?

how may i do this in magento 1.4.2 ?

Very good example for flags. It may help others http://www.phptechi.com/magento-show-country-flags-selector-in-header.html

As stated in that post:

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.

 < ?php if(count($this->getGroups())>1): ?> < ?php foreach ($this->getGroups() as $_group): ?> < ?php echo $this->htmlEscape($_group->getName()) ?> < ?php endforeach; ?> < ?php endif; ?> 

Step 2: Now add entry into page.xml file and file header block ie “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. (ie 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!!.

Currency selector with flag in magento

  1. You need to prepare a flag list (images).
  2. Upload flag list to root/media/flag directory
  3. Rename flags to currency's code (EX: US Dollar -> usd-flag.jpg, Euro -> eur-flag.jpg, Hong Kong Dollar -> hkd-flag.jpg...)
  4. In the template file: app/design/frontend/default/your_theme/template/directory/currency.phtml (or app/design/frontend/base/default/template/directory/currency.phtml), change code to:

     <?php foreach ($this->getCurrencies() as $_code => $_name): ?> <a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);"> <img src="<?php echo Mage::getBaseUrl('media').'flag/'.$_code.'.jpg'; ?>" title="<?php echo $_name ?> - <?php echo $_code ?>" alt="<?php echo $_name ?> - <?php echo $_code ?>" width="20" height="20" /> </a> <?php endforeach; ?> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM