I am starting development of a new module that will have its own node type. I will need to add custom fields to it and wanted to know what the best practice was.

Should I write all the handlers and store the field data in my own tables or can I just use cck to create/manage the fields?

If I use cck should I use some sort of namespace on my fields: field_mn_date where mn is the abbv for my "module name"?

Thanks Guys!

Comments

Karlheinz’s picture

If you're doing everything with CCK, you probably don't even need to write your own module. You can create new fields and whatnot through the Drupal user interface.

But, if you do write a module, it is actually pretty easy to handle your own fields, assuming you already know SQL and PHP.

I found these API pages particularly helpful:
http://api.drupal.org/api/drupal/developer--examples--node_example--node...
http://api.drupal.org/api/drupal/developer--examples--node_example--node...
http://api.drupal.org/api/drupal/developer--examples--page_example--page...
http://drupal.org/node/751826
http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....
http://api.drupal.org/api/group/schemaapi

If you do write your own module, and want to incorporate CCK fields, read these:
http://drupal.org/node/101742
http://drupal.org/node/330421
http://tinpixel.com/node/53
http://api.lullabot.com/file/contrib/cck/includes/content.crud.inc

Good luck!

-Karlheinz

mrconnerton’s picture

Thats a lot of good documentation to read.

mrconnerton’s picture

This will be a public contrib module, so I don't want the user to have to setup the cck fields on their own, thats why I want to do it in the module. but thinking of it, I don't want them to really change the fields either because it might break the functionality of the module...