What is the best practice way to create *mymodule* that provides a content type through CCK? I know how to write a node module using the node api and whatnot, but is there a way I can just define a CCK content type within my module? Or do I have to jump through the hoops of programmatically submitting drupal forms etc (hopefully not!)? Thanks.

Comments

nevets’s picture

Why not just define the content type with CCK? You can even export the type and import for use on another site.

KingMoore’s picture

Well I want the content type to be available whenever someone installs my module...

oligoelemento’s picture

KingMoore’s picture

I am familiar with programatically creating CCK content types. So you think the preferred (or maybe only?) way to provide a CCK content type by a module would be to programatically create it in the modules's install hook, and delete it again in the uninstall hook?

I guess there is no API that is to CCK content types what FAPI is to forms. That would be great.

oligoelemento’s picture

I'm not an expert in Drupal programming, but I also needed to generate CCK content types in a custom module. Then I searched in Google and I found only what I posted.

As I have understood CCK doesn't have an equivalent to FAPI, perhaps due to the variety of contributed CCK fields, but I support you that an API for standard CCK fields would be great.

Then I have only found 2 solutions to the problem of include CCK content types in a custom module:

1. Create CCK content types using the web interface, then export and use the exported data to be imported in the installation of the custom module.

2. Create CCK content types in the custom module installation as database rows knowing CCK content types database structure.

Finally I decided manually export and import nodes and I didn't use any of the 2 solutions :-D

Please, correct me if I'm wrong in my conclusions.

KingMoore’s picture

thanks oli... #1 sounds like probably the way to go... either that or write a node module, but I really don't feel like writing a node module... a bit worried about having all sorts of cck dependancies for my module... hrmmm