Displaying “Select Your Currency” block

Displaying “Select Your Currency” block

The Core of Magento has already a file currency.phtml in app/design/frontend/base/default/template/directory   This block should show up if you select more than one currency in your admin-panel (System > Configuration >Currency Setup ) and then configure them in (System > Manage Currency Rates ) but there are situations where after configure this, the block still not showing up.

So, first of all, after configure the currency in the admin-panel, add this line of code in your catalog.xml (\app\design\frontend\default\yourtheme\layout\catalog.xml):

In the <!– Mage_Catalog –> section, under <reference name=”right”> or <reference name=”left”> (depends of your Theme) add this:

<block type=”directory/currency” name=”currency” template=”directory/currency.phtml”/>

If your “Select Your Currency” block still not showing, you should do the following:

Create a currency.phtml file in the following directory:

\app\design\frontend\default\yourtheme\template\directory\currency.phtml

If you don’t have a “directory” folder, so create it!

The new currency.phtml has to be filled with this code:

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category    design
* @package     base_default
* @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
* @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Currency switcher
*
* @see Mage_Directory_Block_Currency
*/
?>
<?php if($this->getCurrencyCount()>1): ?>
<div>
<div>
</div>
<div>
<select name=”currency” title=”<?php echo $this->__(‘Select Your Currency’) ?>” onchange=”setLocation(this.value)”>
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value=”<?php echo $this->getSwitchCurrencyUrl($_code) ?>”<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected=”selected”<?php endif; ?>>
<?php echo $_name ?> – <?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endif; ?>

Then, you have to give it style, going to your styles.css, add or modify this:

.block-currency .head {
background-image:url(“../images/select_your_currency.gif”);
background-position:0 0;
background-repeat:no-repeat;
}

This is post is in How To

11 Comments already...

  1. This doesn’t work for me. As soon as I place that line in my catalog.xml file, I get the following error:

    Fatal error: Call to a member function addToChildGroup() on a non-object in /home/thelucky/public_html/app/code/core/Mage/Core/Block/Abstract.php on line 654

  2. bobby you

    hi,i created “directory” folder,and currency.phtml but still no Displaying “Select Your Currency” block,you see http://www.yaabay.com

  3. This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It?s the old what goes around comes around routine. XR2011K6

  4. greate!! it is work thank you !!

  5. We’re a group of volunteers and beginning a new initiative in our community. Your weblog supplied us with valuable info to work on|.You have done an impressive job!

  6. The code:
    block type=”directory/currency” name=”currency” template=”directory/currency.phtml”/>

    is wrong the correct is the following:

    Your work is great, thank you.

  7. The code:

    is wrong the correct is the following:

    Your work is great, thank you.

  8. The code:
    block type=”directory/currency” name=”currency” template=”directory/currency.phtml”/>

    is wrong the correct is the following:
    block type=”directory/currency” name=”directory.currency” template=”directory/currency.phtml”/>

    Your work is great, thank you.
    (Sorry, something happends with the others comments)

  9. I have attempted to install Magento e-commerce on my web server with Webcity.com.au, and have begun the install.php process, but in the third step I always get a message saying “PHP Extension “pdo_mysql” must be loaded”. What us pdo_mysql and how do I install this on the server?

Leave a Reply