Money CCK field port to Drupal 6?

newmediaist - October 16, 2008 - 16:04
Project:Money CCK field
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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!

#1

Wim Leers - October 16, 2008 - 21:58

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.

#2

ztyx - October 27, 2008 - 12:17

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.

#3

ztyx - October 27, 2008 - 13:12

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.

#4

Wim Leers - October 27, 2008 - 16:00

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

#5

ztyx - October 27, 2008 - 17:21

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.

#6

ztyx - October 27, 2008 - 21:11

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

#7

markus_petrux - November 9, 2008 - 20:42

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

#8

markus_petrux - November 9, 2008 - 21:00
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.

#9

Wim Leers - November 9, 2008 - 22:09

Go go Markus! :)

#10

ztyx - November 10, 2008 - 01:32

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.

#11

ztyx - November 9, 2008 - 22:38
Status:active» needs work

#12

markus_petrux - November 9, 2008 - 23:58

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

#13

Wim Leers - November 10, 2008 - 01:05

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! :)

#14

ztyx - November 10, 2008 - 01:29

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

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

AttachmentSize
money.drupal-6.incomplete.patch 13.91 KB

#15

markus_petrux - November 15, 2008 - 14:39
Version:5.x-1.x-dev» 6.x-1.0-beta1
Status:needs work» 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 :)

#16

Wim Leers - November 15, 2008 - 14:59

Great Markus, thanks :)

#17

markus_petrux - November 16, 2008 - 11:45
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. :)

#18

ztyx - November 16, 2008 - 12:56

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?

#19

markus_petrux - November 16, 2008 - 14:39

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.

#20

Wim Leers - November 16, 2008 - 21:29

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.

#21

markus_petrux - November 16, 2008 - 21:47

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?

#22

Wim Leers - November 17, 2008 - 14:54

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 :)

#23

markus_petrux - November 17, 2008 - 15:27

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).

#24

markus_petrux - November 19, 2008 - 17:24
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.