Is anyone working on a Drupal 6 port of the money module?
I'd offer to chip in, but wouldn't know where to begin!

CommentFileSizeAuthor
#14 money.drupal-6.incomplete.patch13.91 KBztyx

Comments

wim leers’s picture

Sorry, I'm no longer maintaining this module: http://wimleers.com/blog/how-much-is-too-much. Unfortunately, nobody has stepped up yet to maintain it.

ztyx’s picture

Hi, I'm also offering my help in this matter although I need to look into the new CCK API before I know where to begin. Anyone who's got any good resources for CCK (Drupal 6) programming?

Holler if there's anything I can do without CCK knowledge.

ztyx’s picture

I'd offer to chip in, but wouldn't know where to begin!

Yes, CCK currently lacks documentation there is some information about how to upgrade CCK Fields from 5.x to 6.x and a tutorial on how to create a CCK field in 5.x. They are all part of the CCK documentation. But my best bet is to have a look at the Number and Text modules (in CCK bundle) that are supposed to be thoroughly documented.

wim leers’s picture

ztyx: Awesome! Does this mean you'd like to become the maintainer for this module? :)

ztyx’s picture

Wim: Haha, you're good! :) I will see what I can do with the code. If I manage to port it to D6 I will also consider maintaining it.

ztyx’s picture

newmediaist: The Currency CCK module also has a lot of comments.

markus_petrux’s picture

Hi all,

I've been talking via emal with Wim, and I'll be porting the module to CCK 2 / Drupal 6. I'm now finishing the code for the Formatted Number CCK module, and then I'll start working on this one. The other module is almost ready. I just need to figure out which is the recommended method to implement field validation, which seems to me a bit inconsistent (ref. #332176: Best practices for implementing validation routines for CCK fields?).

The Money CCK field for CCK 2 / Drupal 6 will also require the Format Number API module, which is a small thing that will offer a consistent method to format number with site/user specified thousands separator and decimal points.

I'll be updaing this issue as progress is being made... and you can also check the commit log... I hope to get soon access to create releases and so on too.

Thanks to Wim for his confidence to me. :)

Cheers

markus_petrux’s picture

Title: Drupal 6 port? » Money CCK field port to Drupal 6?

Let me change the issue title. It's easier for me to track it from the "My recent posts" page.

wim leers’s picture

Go go Markus! :)

ztyx’s picture

Status: Needs work » Active

Hi again Markus,

It seems you and me are working on the same projects nowadays :-P It's also very funny that I was planning on using Format Number API for this module...

As I am pretty certain you are the better Drupaler and programmer of the two of us I am attaching a patch (diff -N money money.new) of what I've been working on. The patch contains the code I've changed so far, but also the new file money.install (which for some reason could not be attached to my comment).

My code is not functional, but who knows, maybe you can use snippets of it. I believe the field part should work and the widget part is the one that needs more attention. I had just figured out pretty much what to do with it, but it'll probably take me a week or two to implement it. Also Format Number needs to be incorporated while removing the old formatting code, but you know all that. ;-)

Good luck,

Jens

Edit: This patch had the wrong (non-unified) format. Have a look this patch instead.

ztyx’s picture

Status: Active » Needs work
markus_petrux’s picture

Install script comitted:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/money/money...

Though, I locked the installation using hook_requirements('install') until the real coding for the port starts to get into... hopefuly next week.

@Jens: thank you very much, I'll take a look. However, patches need to be generated using unified style. Please, see: http://drupal.org/patch/create

wim leers’s picture

Wow! It's great to see so much interest in this module, and even more to see the community bringing two developers together :)

Rock on, Drupal! :)

ztyx’s picture

StatusFileSize
new13.91 KB

@Markus: My apologizes, I forgot the unified flag. I'm attaching a new, correctly formatted, patch.

@Wim: Well, it's a practical module! :)

markus_petrux’s picture

Version: 5.x-1.x-dev » 6.x-1.0-beta1
Status: Active » Fixed

Hi all, :)

DONE:

TODO:

  • Views support for separate Amount and Currency fields (patches welcome).
  • Update the project page with information and requirements of the D6 version of the module. Project maintainership transfer already requested a week or so ago.
  • Fix any bug that may arise.

I'm setting this issue as being fixed. It almost is. Please, check out BETA1 and open separate issues for anything that you may find.

Cheers :)

wim leers’s picture

Great Markus, thanks :)

markus_petrux’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev

Yep!

I added/fixed a few things, including the move of allowed currencies option from field settings to widget settings (makes more sense). I tested it all and I feel it's pretty stable, so I released RC1.

Again, please open separate issues for anything that you may wish to get fixed before 1.0 is launched ...with all its underlying consequences. :)

ztyx’s picture

I just need to figure out which is the recommended method to implement field validation, which seems to me a bit inconsistent (ref. #332176: Best practices for implementing validation routines for CCK fields?).

@markus: Did you get an answer to this?

markus_petrux’s picture

Nope. So I had to figure out that myself.

AFAICT, the validation implemented via FAPI is only invoked when FAPI is involved. That is when a form is processed.

CCK invokes hook_field('validation') when a form is processed, but also when a field value is computed programatically. For example, when a default value is generated using PHP code. Another use of this is when nodeapi('validate') is processed, when a "populate a field" action is processed, etc.

So if you implement validation only using FAPI, there may be situations where invalid data gets into the database, which is something that may happen in builtin CCK Number because it validates different things in both validations routines.

wim leers’s picture

This is your baby now, but I have to disagree with

move of allowed currencies option from field settings to widget settings (makes more sense)

Allowed currencies is associated with the field, not with the widget.
The widget is just one of many possible ways for representing the input. Therefore it should be the same for all input representations. Therefore it should be a field setting.

markus_petrux’s picture

hmm... I haven't used CCK in D5, so I can't tell.

AFAICT, in D6 one of the differences between field settings and widget settings is that the former are global, and the later local. You can create a field for one content type and reuse the field definition across content types. If you do, then CCK creates a separate table for the field, so the field settings should be the same for all content types reusing a particular field.

Moving the allowed currencies option to the widget settings allows you to share a field across multiple content types, but have different options for the widget, including allowed currencies, the format of the select opcions (currency name or currency code), while the internal data format remains the same (which is what's configured in field settings).

If you move the allowed currencies option to field settings, you'll have to create different CCK fields if you need to use a different set of currencies for different content types, and CCK will use different tables for them. That means you'll be limited when using views, where you'll be forced to use more joins, or you'll have to add more conditions to get a list of nodes of different types that have a money field greater than X value, for example.

If you move the allowed currencies option to widget settings, then it's up to the site admin create one single field or more. It gives you more freedom.

Thoughts?

wim leers’s picture

Interesting, I didn't know about the differences in setting sharing when sharing a field across content types. I'd consider that a bug in CCK. I didn't know that, so you've completely convinced me that this is the best solution for now, i.e. till CCK 3 or so :)

markus_petrux’s picture

Sweet! :)

I agree with you that "allowed currencies" conceptually belongs to field settings, but I opted for the option that offers more freedom to site admins.

Now, if there's no bug in current code, we could release this. Though, we would have to review the information of the module in the project page (requirements, description, differences between D5 -vs- D6, ...). I would, if I could :( (Related request: #332196: Request to take over maintainership of the Money CCK field module).

markus_petrux’s picture

Status: Fixed » Closed (fixed)