Great Module !!!
I tried to add this block to the CVS - but i don't know how ...
//################################################################################
function currency_block($op = 'list', $delta = 0, $edit = array())
{
if ($op == 'list') {
$blocks[0] = array('info' => t('Currency Converter'),
'weight' => 0, 'enabled' => 1, 'region' => 'left');
return $blocks;
}
else if ($op == 'configure' && $delta == 0) {
$form['currency_block_title'] = array(
'#type' => 'textfield',
'#title' => t('Block Title'),
'#default_value' => variable_get('currency_block_title', t('Currency Converter')),
);
return $form;
}
else if ($op == 'save' && $delta == 0) {
variable_set('currency_block_title', $edit['currency_block_title']);
}
else if ($op == 'view') {
switch($delta) {
case 0:
$block = array('subject' => variable_get('currency_block_title', t('Currency Converter')),
'content' => currency_contents());
break;
}
return $block;
}
//################################################################################
| Comment | File | Size | Author |
|---|---|---|---|
| #49 | Screenshot.png | 3.67 KB | nicholaspapazoglou |
| #48 | currency-101106-48.patch | 15.56 KB | agileware |
| #47 | currency-101106-44.patch | 15.56 KB | agileware |
| #43 | currency-101106-43.patch | 15.55 KB | agileware |
| #42 | images.zip | 494 bytes | agileware |
Comments
Comment #1
Leeteq commentedhttp://drupal.org/node/134786
Comment #2
kbahey commentedMarking this as active, and the other one as duplicate, since this is the one that has code in it.
Comment #3
johnhanley commentedAbove block is inoperable without corresponding currency_contents() function.
Comment #4
kenorb commentedCan anybody put some working block code?
Thanks.
Comment #5
andrew.eatherington@gmail.com commentedDoes this enable displaying of currency within a block? Where do you put this code?
Comment #6
kbahey commentedCode is incomplete ...
Comment #7
asak commentedAny update on this issue...?
Comment #8
pmark23 commentedDoes this code work with 6.x? I wasn't able to get it working either.
Comment #9
jptarantoWonder if there is a chance we can someone to re look at getting this patch to work with d6? Thanks.
Comment #10
johnhanley commentedThe patch never worked for D5 so unfortunately there's nothing to port.
That said it wouldn't be that difficult to create... someone just needs the inspiration to do so.
Comment #11
jptarantoInspiration:
It's a pretty darn unique module right here. There isn't actually anything else like this for Drupal...
And it's almost feature complete... all it needs is a block display.
Once that's done, it would be pretty killer.
Comment #12
johnhanley commentedDo you mean you want the currency converter form in a block?
Comment #13
liliplanet commentedcurrency converter in a block would be fabulous, thanx!
Comment #14
jptarantoYes indeed. If you or someone else could write a working patch it would be grand.
Comment #15
johnhanley commentedAs requested here's the currency exchange form in a block. This was written for and tested with Drupal 5, but conversion to Drupal 6 would be a breeze. A nice addition would be to eliminate the refresh and retrieve the conversion data with AJAX.
The form, validate and submit code is copied directly from currency.module. The rest of code outputs the form and related messaging in a block.
To use:
1) create a directory called currency_block inside the currency module directory
2) copy/paste each portion of code below into your favorite IDE or text editor and save as currency_block.info and currency_block.module respectively
3) enable the module, then the block
4) happy converting!
currency_block.info
currency_block.module
Comment #16
kbahey commentedBacteria Man
Is it possible to roll this as a patch, so it can be reviewed and committed to the module?
Thanks
Comment #17
johnhanley commentedAre you suggesting to create a patch for the above separate module (to be included in the currency module distribution) or roll the code into currency.module?
I put this together almost as a lark and it should be tested before deciding to do either. The currency dropdowns are excessively wide due to one lengthy currency name, which may make the block column width too wide for ordinary themes.
Comment #18
kbahey commentedIt is a useful feature to have, and making it part of standard module may be helpful.
Regarding the long currency name, perhaps you can truncate them to a reasonable length.
Any module that implements a block is by definition optional: the site admin decides whether to enable a block or not, so there is no harm in including it as is.
Post a screen shot here and let us see what everyone thinks: put it in the module, or keep it separate.
Comment #19
johnhanley commentedWell, I like the idea of consolidating and rolling the block code into currency.module. It'd be nice to reuse currency_form_validate(), but the block submit function will have to remain separate because a custom message type is passed to drupal_set_message() at the end of currency_block_form_submit() so that the form errors and exchange rate reporting appear in the block instead of the content area. Sidebar: contrary to the drupal_set_message documentation you can define as many custom message types as you like. A corresponding class name just needs to be added to the theme stylesheet so that the format is properly outputted.
If you decide to keep things as a separate module you simply need to create the above files and check them into CVS.
Comment #20
jessicakoh commentedsubscribing.
Comment #21
edib commentedmodules page says this module does not work with drupal version 6.10.
any idea?
Comment #22
kbahey commentedHow is your comment related to this issue (having a "block")?
If you want to say something unrelated, then open a new issue. Don't confuse others by posting in an existing unrelated issue.
And even what you are saying is false: the module has a 6.x-1.x release, and nothing says it does not run on 6.x.
Comment #23
alarez commentedHi,
I'm Trying to install this module in my Drupal Real Estate Site and it says:
This version is incompatible with the 6.13 version of Drupal core.
Any Ideas,
Can anyone point my in the right direction please?
Comment #24
kenorb commentedalerez:
are you sure that you downloaded 6.x version?
Comment #25
alarez commentedHi,
I have
• Currency 6.x-1.1
• Currency API 6.x-1.1
• And the currency block posted here by Bacteria Man.
Thanks for your help...
Comment #26
kenorb commentedalarez:
If you have latest version for 6.x, you should have in your currency.info line:
core = 6.x
This making it compatible with 6.x
Comment #27
jdeg commentedHi,
I have the same problem of alarez
I'm using Drupal 6.11 and when i try to install the module i get this message:
This version is incompatible with the 6.11 version of Drupal core.and an "x" image instead of the checkbox. (please see attach)
Thanks in advance.
Comment #28
johnhanley commentedAs the post clearly states, the currency exchange form in a block module was created for Drupal 5. Besides adding "core = 6.x" to the currency_block.info the Form API related functions need to be converted to Drupal 6. This is a relatively trivial matter, but I personally don't have the bandwidth right now.
Comment #29
WildfireXT commentedNope. Don't see it even when I did what was mentioned. To recap:
- I'm using version 5.3 of the currency exchange mod and Drupal 5
- I created the folder currency_block and put the files currency_block.info and currency_block.module inside
- I copy pasted your code into the 2 files .info and .module
- I copied the currency_block over to currency folder
- I disabled, uninstalled, currency module
- I uploaded new currency module, enabled it, ran update.php
After that what was supposed to happen? I don't see an entry for a new module in the modules page. I don't see a block named "currency exchange" either.
Comment #30
WildfireXT commentedUh scratch that.
Seems like I got a problem with proper spelling after 20 years of education.
Please ignore last.
Comment #31
ppmax commentedI built a D6 module/block for converting currency based upon code posted above. I also created a plugin for the Ajax Forms module so that you can submit a number for conversion via Ajax. The result is then "jQueried" into a div.
If anyone wants the code let me know--I could post it here but have to run.
PP
Comment #32
ITMonkey commentedppmax, I could do with that D6 block, that would be awesome!
Comment #33
asak commentedhey ppmax - bring it on ;)
Comment #34
ppmax commentedNo problems--
I've uploaded two zip files. Here's a couple notes:
ppcustom_currency_block: this is the block module that depends on Currency Exchange. (The module has a dependency in it). This module could be modified to sit inside the Currency Exchange module--but I didnt go that route because I didnt want my stuff to get hosed if Currency Exchange was updated. If the maintainer wants to add this to the project it's cool with me ;)
ppcustom_currency_form: this is the plugin for the Ajax module and has to be installed in the /sites/all/modules/ajax/plugins directory. I cant remember if this module needed to be explicitly activated or if Ajax will just pick it up. Needless to say, the ajaxilicious currency exchange block needs this module to be ajaxtivated.
For my own sanity I usually name all my custom modules ppcustom_* and group them all in the zPP Modules "package." Once you've added these modules in their proper places go to admin/build/modules and scroll down to the bottom of the page to activate them.
UPDATED: I just checked and my Ajax plugin will show up in the Ajax group and needs to be explicitly activated. You'll also need the jQuery goodies too.
Last notes:
I haven't added any js validation so when you enter a zero or any non-numeric value in the Amount form field you'll get "undefined undefined" and an ugly drupal message above the form. If I have time to fix those annoyances I'll post an update.
If you "Inspect Element" with Firefox/Firebug you'll see a
<div id="results"></div>. You can add a selector to your stylesheet to style this content any way you like.If you find any issues/bugs post here and I'll see what I can do when I get time.
Hope this helps someone--
pp
Comment #35
jeeba commentedHey ppmax your module is incredible!!. Thanks for it.
Anyway i im using:
Drupal 6.15
Currency API 6.x-1.x-dev
Ajax 6.x-1.x-dev
And your Block module. It install perfect, but maybe theres some new changes on one on those modules because it give me an error in the file ajax_ppcustom_currency_form.js, Its seem that the javascript variable returnet by ajax: args.data no longer exists so :
$('#results').replaceWith('<div id="results">' + args.data.options.result + ' ' + args.data.options.to + '</div>');give an error. The solution in easy just replace that line with:
$('#results').replaceWith('<div id="results">' + args.options.result + ' ' + args.options.to + '</div>');Note that we are not using args.data just args.options. Hope iot helps
PD: Also why not use $('#results').html(args.options.result); instead of replaceWith?
Comment #36
kentjames1980 commentedHey all
Cool block module and something which is much needed when you consider there is a xe.com block on joomla already (spit... lol)
Anyways, ive enabled it all and got an issue - once you click on convert nothing happens?? Any ideas??
Currency is all working fine btw...
Thanks in advance!
Comment #37
Hardrocker commentedCurrently I am using views to create the block, but unfortunately the block only updates when you do a conversion of the same currency again. I don't see the point of adding block support when the module is integrated with views. It would be nice to see the views block display updated dynamically though. Great module by the way!
Comment #38
Hardrocker commentedHere is a screenshot of what the views block looks like. I even added a link to the bottom of the block to link to the currency calculator page.
Comment #39
agileware commentedI have not tried the module in #34 but here is a solution I made for a client for the same requirement.
It is not a separate module but a patch for this module.
The functionality is based on the Yahoo converter at http://finance.yahoo.com/currency-converter
There are also a couple of extra options that are available if the ubercart uc_cart module is enabled.
They are:
* An option that gives a link in the converter block that when clicked loads the users cart total into the converter.
* An option that automatically loads the users cart total into the converter when the block is viewed on the cart page.
The block is themeable.
To use this just apply the patch (it will apply cleanly to both 6.x-1.2 & the current 6.x-1.x-dev) with:
patch -p0 < currency-101106-39.patchand unzip the images.zip file.
Do both of these from the currency module directory.
Comment #40
agileware commentedFrom looking at hardrocker's comments my solution might be for a different issue.
If my patch is off topic let me know and I'll post a new issue.
Comment #41
agileware commentedHere is an updated version that adds one more ubercart related option.
Similar to the auto calculation of the cart total, the new option is an auto calculate for the checkout page.
So if on the checkout page the total is auto calculated.
The calculation works on the subtotal before any taxes are added (you generally don't want taxes for overseas customers who would be using the currency converter). Also if you update shipping or something and the subtotal is recalculated this will be reflected in the converter.
There has also been a little cleanup of code in the currency_load_cart_total.js file.
It still required the images directory zip in #39 to be added.
Comment #42
agileware commentedSorry, must have missed the images zip file. Here it is.
Comment #43
agileware commentedSorry for so many posts but here is an updated version.
This patch fixes a bug when you press tab in the from amount field and the from currency is disabled.
It also adds a setting that allows you to set the number of decimal places to round the converted value to.
Apply this patch along with unzipping the images.zip in #41.
Comment #47
agileware commentedUpdated patch, fixing missing base_path function for image source.
Comment #48
agileware commentedSame patch, correct file name this time (bloody comment spammers!!)
Comment #49
nicholaspapazoglou commentedHi ppmax ,
I've just installed your module. I have the block on the right side bar. If the page /currency is loaded on the left, the module works fine. If an other page is loaded on the left, it redirects me to a blank page with a small box with some code inside an if I drop down in this box, I can see the result at the end...
This message is:
{ "status": true, "updaters": [ ], "debug": [ ], "messages_error": [ ], "messages_status": [ ], "messages_warning": [ ], "redirect": null, "preview": null, "form_id": "ppcustom_currency_block_form", "options": { "enabled": true, "form_submitted": 1, "result": 78.7, "to": "Euro (EUR)" } }
You can also see my screen-shot.
Would you help, please?
Comment #51
ayalsule commented+1 Great idea.
Comment #52
amateescu commentedThis will have to wait a bit until the refactoring from the 7.x-2.x branch is completed. Then we'll decide if this block belongs to the basic currency exchange submodule or to another project (that will be the home of currency exchange providers).
Comment #53
artiman commentedi'm trying to use currency module in a block but i can not figure it out how , i'm running drupal 7,
any suggestion ?
i have an error message which say's this module is incompatible with this version if drupal .
Comment #54
xanoClosing this issue in favor of #1883158: Add a "Currency conversion rate database table" submodule. Please follow it if you'd like to be kept up to date on this feature.
Comment #55
xanoAlso, 7.x-1.x has some Views integration for its Exchange Rates table, which should allow you to create blocks, pages, etc. that display a table with exchange rates.