Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:02:24+00:00 2026-06-06T21:02:24+00:00

I want to have a multi-language magento site use a flag image instead of

  • 0

I want to have a multi-language magento site use a flag image instead of a language selector box for user to select language of page. There is a nice article on this at http://www.atwix.com/magento/replace-language-selector-flag-icons/
Only issue is that we use “Add store codes to url” option. I hacked this code, but it can use some refinement and make it more Magento looking.

    <?php if(count($this->getStores())>1): ?>
    <div class="form-language">
        <div class="langs-wrapper">
        <?php foreach ($this->getStores() as $_lang): ?>
            <?php if ($_lang->getCode() != 'default'): ?>   
            <?  
                $base_url = Mage::getBaseUrl();
                // remove language in base url
                $base_url = str_replace('/en/' , "" , $base_url);       
                $base_url = str_replace('/fr/' , "" , $base_url);                   
                $current_url = $this->helper('core/url')->getCurrentUrl();
                // take out base url and language code
                $rest_of_url = str_replace($base_url , "" , $current_url);                  
                $rest_of_url = str_replace('/en/' , "" , $rest_of_url);     
                $rest_of_url = str_replace('/fr/' , "" , $rest_of_url);      
                // assmble new url
                $new_url = $base_url . '/' . $_lang->getCode()  . '/' . $rest_of_url;                       
            ?>      
            <a class="lang-flag" href="<?php echo $new_url ;?>"><img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt=""></a>
            <?php endif;?>
        <?php endforeach;?>
        </div>
    </div>
    <?php endif;?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:02:27+00:00Added an answer on June 6, 2026 at 9:02 pm

    Template file (path/to/template/file.phtml):

    <?php if(count($this->getStores()) > 1): ?>
    <div class="form-language">
        <?php foreach ($this->getStores() as $_lang): ?>
            <?php $selected = $_lang->getId() == $this->getCurrentStoreId() ?>
            <a class="lang-flag<?php $selected && print ' selected' ?>" href="<?php echo $_lang->getCurrentUrl() ?>">
                <img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt="<?php echo $this->htmlEscape($_lang->getName()) ?>">
            </a>
        <?php endforeach ?>
    </div>
    <?php endif ?>
    

    Add this lines to your layout-update xml file (if you haven’t defined switch block):

    <block type="page/switch" name="lang.switcher" template="path/to/template/file.phtml" />
    

    If you have already one:

    <reference name="store_language">
        <action method="setTemplate"><tmpl>path/to/template/file.phtml</tmpl></action>
    </reference>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-select list box. I want to be able to select a
So I want to make my page to have multi language function, like German,
I have a multi language app. I want to give the user the ability
I have a multi-language page, I want to detect client browser's language then make
I want to have a multi language site. Now, I have 2 domains. The
I have a multi-lingual page where I want to display form validation error in
I have multiple multi-select boxes with the same class and i want to unselect
I have a multi-select <asp:listbox> and a button. I want to disable the button
I have a multi-language website. I want a module to add multiple version of
I have this content structure for a multi language site. Content Danish Forside Om

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.