Yahoo Currency Converter - AJAX version
Written by kksou   
Friday, 29 August 2008

This module allows you to add the Yahoo Currency Converter in a module position.

The module makes use of the Currency Converter from Yahoo Finance.

Important Note: Yahoo Finance has changed its interface to pure AJAX module. As a result, it is no longer possible to retrieve the converted currencies using fread() or the cURL library direct from http://finance.yahoo.com/currency-converter.

In case you're wondering where does the program get the currency conversion rate from? First go to http://finance.yahoo.com/currency-converter, click the link "View 5 Day Trend", then on the left navigation bar, you will see one more link "Summary". Click on that link. This is where the program gets the rate for the currency conversion.

Prefer Google Finance?

If you prefer to use the Currency Converter from Google Finance as oppose to Yahoo Finance, here it is:
Google Currency Converter - AJAX version

Live Demo

There are four demos available:


Latest Version

v1.0.5 (for Joomla 1.0) and v1.5.5 (for Joomla 1.5)
Released September 1, 2009

Thanks to Juan Manuel Rico who informed me about Venezuelan's new currency. Have changed the code from Venezuelan Bolivar (VEB) to Venezuelan Bolivar Fuerte (VEF).

v1.0.4 (for Joomla 1.0) and v1.5.4 (for Joomla 1.5)
Released August 31, 2009

This is in response to Alamshahi's post titled "uncorrect results : missed digits".

The error occurred when Yahoo returns a conversion rate greater than 1,000. The original program was "confused" because of the ',' in 1,000. Have fixed the bug in this version.

In this new release, I've also added support for retrieving yahoo currency data using file_get_contents() or fread(). So for those people with no cURL library, you can now use the module using file_get_contents() or fread().

Unique Features

  • Performs currency conversion by connecting in real-time at the backend to the Currency Converter from Yahoo Finance. So you get the most up-to-date currency rate as provided by Yahoo Finance.
  • Uses AJAX to display the result - no reloading of pages required!
  • Full CSS support! This means that you can set the font family, font size, foreground and background color of the input field, submit button, etc.
  • The module can be included in a content item! (see below for details)

Including this module in Content Item or Article

Since this is a standard Joomla module, you can easily include this module into a content item or article with the use of {mosloadposition} (for Joomla 1.0.x) or {loadposition} (for Joomla 1.5.x).

You can take a look at the demo here.

Download

How to install

  1. Download and install the "Yahoo Currency Converter" module.
  2. Make sure the module is published / enabled.
  3. Select a module position where you want to place the module.

That's it! You're now ready to use the Yahoo Currency Converter right inside your Joomla website!

Parameters

You can set the following in the Parameters page:

  1. Use which method to retrieve data: There are now three methods to retrieve data from Yahoo Finance.
    • The default method uses fread().
    • You can also use file_get_contents(). Note that file_get_contents() is only available in PHP5 and above.
    • Use the cURL library. For this method, you need to make sure your PHP has the cURL library installed.

    Use the default method fread() first. If it doesn't work, then try file_get_contents(), and then the cURL library.

  2. Currency From: This is the default "currency from" that will be displayed when the module is first loaded.
  3. Currency To: This is the default "currency to" that will be displayed when the module is first loaded.
  4. Label for Submit Button: Default is "Convert". You may change this to your language.
  5. Use CSS for highlight: When this is set to "No", result will be highlighted in the default yellow background. If you do not not like the default yellow background color and wish to change this to some other color, change this to "Yes". However, when you set this to "Yes", you need to define the color in the .css file of your template. Please see below for details.
  6. Layout style: There are three layout styles to choose from:
  7. Style 1 This one has the minimum width, and is ideal when you are positioning it in the left or right column.
    Goolge Currency Converter - Style 1
    Style 2 This is the same layout as used in Google Finance.
    Goolge Currency Converter - Style 2
    Style 3 This one shows everything in one line. Ideal for use in top or bottom banner-type module position, or in content item.
    Goolge Currency Converter - Style 3

Styling the Module using CSS

You can set the style of every item within the Yahoo Currency Converter to the exact format you want through CSS. This means that you can set the font family, font size, foreground and background color of the input field, pulldown menu, submit button, etc.

For example, if you're using the default Joomla 1.5 template, define the following style in <joomla root folder>/templates/rhuk_milkyway/css/template.css. If you're using the default Joomla 1.0 template, define the following style in <joomla root folder>/templates/rhuk_solarflare_ii/css/template_css.css.

  1. Input Box
  2. div.yahoocurrency input.inputbox {
    	font-family: Verdana;
    	font-size: 12pt;
    	font-style: italic;
    }
    
  3. Submit Button
  4. div.yahoocurrency input.button {
    	font-family: Verdana;
    	font-size: 10pt;
    }
    
  5. The options of the pulldown menu (i.e. the list of currencies)
  6. div.yahoocurrency option {
    	font-family: Verdana;
    	font-size: 10pt;
    }
    
  7. The selected option of the pulldown menu (i.e. the selected currency)
  8. div.yahoocurrency select {
    	font-family: Verdana;
    	font-size: 10pt;
    }
    
  9. Input Label (the text "Convert" and "Into")
  10. div.yahoocurrency .input_label {
    	font-family: Verdana;
    	font-size: 12pt;
    }
    
  11. The result
  12. div.yahoocurrency .result {
    	font-family: Verdana;
    	font-size: 12pt;
    }
    
  13. The highlight for the result. Note: Don't forget to set the "Use CSS" to "Yes" in the Parameters page in order to change the background color of the highliglht.
  14. div.yahoocurrency .highlight {
    	color: #333366;
    	background-color: #0033ff;
    }
    
  15. Use this if you wish to set the background color of the entire module block:
  16. div.yahoocurrency {
    	background: #33FF66;
    }
    

Version History

  • v1.0.1 (for Joomla 1.0) and v1.5.1 (for Joomla 1.5)
    Released September 3, 2008
    • Fixed a bug in Internet Explorer. The module will now work correctly in IE.
    • Support for non-javascript browser and browsers which do not allow javascript! For these browsers, since AJAX cannot run, there will be reloading of the page when the submit button is clicked. The same result will appear for both the AJAX and non-AJAX mode.
  • v1.0.2 (for Joomla 1.0) and v1.5.2 (for Joomla 1.5)
    Released September 28, 2008
  • Thanks to Andre who pointed out that the converter keeps "spinning" when one enters a large amount e.g. 10,000. This is because the previous version did not test for the comma sign.

    The new version has fixed this.

  • v1.0.3 (for Joomla 1.0) and v1.5.3 (for Joomla 1.5)
    Released January 17, 2009
  • Yes, the Yahoo Currency Converter is back again!

    Managed to find another Yahoo Finance page that allows us to grab the cuurency conversion rate.

    Please refer to here for more details.

FAQ (Frequently Asked Questions)

Q1: I modified the stylesheet as outlined in Styling the Module using CSS. But the new styles do not seem to take effect.

A1: Note that after you have modified the stylesheet, you have to reload the page so that the stylesheet is reloaded.

I've also found that for some browsers, they still use the "cached" version of stylesheet even when you click the "Reload" button. In such case, you need to clear the cache so the the modified stylesheet gets reloaded.

Q2: I changed the format from Style 1 to Style 2. But the Yahoo Currency Converter are still displayed as Style 1.

A2: After you have changed the style in Modules Manager from Style 1 to Style 2, make sure you click the "Reload" button on the page in which the Yahoo Currency Converter is displayed.


User reviews   Average user ratings:    4.5   (from 6 users)
  1. peter
    September 07, 2008 10:58am

  2. lumo
    April 21, 2009 3:05am
    Error shown

    Hi,
    Great module but a small problem.
    On a Joomla 1.0 install with open_basedir set I get this error.
    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set.
    After a bit of Googling I commented out the line 185 in mod_yahoocurrencyconverter_lib.php.
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    This killed the warning and themodule works fine.
    My question is, is this safe or will it harm the module somehow?

  3. lumo
    April 21, 2009 3:48am
    Error shown

    Hi,
    Great module but a small problem.
    On a Joomla 1.0 install with open_basedir set I get this error.
    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set.
    After a bit of Googling I commented out the line 185 in mod_yahoocurrencyconverter_lib.php.
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    This killed the warning and themodule works fine.
    My question is, is this safe or will it harm the module somehow?

  4. lumo
    April 21, 2009 5:37am
    Error shown

    Hi,
    Great module but a small problem.
    On a Joomla 1.0 install with open_basedir set I get this error.
    Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set.
    After a bit of Googling I commented out the line 185 in mod_yahoocurrencyconverter_lib.php.
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    This killed the warning and themodule works fine.
    My question is, is this safe or will it harm the module somehow?

  5. alamshahi
    September 01, 2009 7:36am

  6. www.hotelsinmanchesteruk.co.uk
    November 02, 2009 4:16pm
    www.hotelsinmanchesteruk.co.uk

    thanks for this script

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved