CCK is Dangerously Sexy in Drupal 5.0

03.02.2007

CCK no longer neuters nodes.  To clear the record, CCK is drupal's most kick ass contributed module, and I recommend it in just about any situation and enviroment.

My reasoning for this 180 degree reversal in opinion are firstly two new modules included in cck:

content_copy.module -- this module allows you to import/export CCK node types from installation to installation. Using drupal_macro() (found in the devel.module), or drupal_execute(), one could theoretically automate these imports in .install file. I know its possible, but I haven'yet completely worked out some details... (namely, that CCK node tables don't appear to exist at the moment drupal_execute, or macro is executed). maybe I'm just an idiot... I don't know....

I'll write up the solution as soon as I have time to solve it.

fieldgroup.module -- this module allows you to organize your node form fields arbitraily into fieldsets, with controls for weight, and labels included. I couldn't ask for more.

Secondly, some changes in drupal 5 have made CCK an unbelievably powerful tool for developers. In drupal 5, CCK can add fields to any node type -- does your blog post need a special image field? CCK+ imagefield can do it in 3 minutes (including installation times, assuming you know how to use a shell...)  

Thirdly, CCK appears to be the future of drupal, so better join the CCK crew now, before its to late.

Finally, in drupal 5, CCK can interact with node hooks.

Soon, I hope to leave work with enough energy to write a tutorial on CCK and node hooks, but for now, I can only give you the clue:

In hook_node_info() declare your node types, and set 'module' to whatever module you are developing. Add your fields using CCK, and your module's view,  validate, submit, prepare, form, insert, update hooks will all have your cck node data available.

Now, back to the salt mines for me....

Comments

Question and suggestion for your tutorial

I found your post here when I was searching for a solution for an actual cck theming problem. Maybe it's of interest for your tutorial?!

I have a content type that's enriched with some cck fields. Now, when I call theme_node($node, TRUE, FALSE) to get the node's teaser in a block (with php code) - I get only the standard node teaser (that is a title and a part of the content) and not a piece of my cck additions.

Would that be a nice exercise for your tutorial?

More info

Like you i've been playing around with cck in d 5.0. And i noticed the cool feature about adding a cck field to ANY node without having to create a brand new cck content type. very cool. someone on the forums also brought my attention to the cck import/export. very cool.

BUT..

1)i'm stuck when it comes to trying to programatically implement these export imports in code so you don't have to do them manually. so i can't wait for your tutorial about this when you get around to it. specifically, is it possible to create a module that i can pick up and drop into any site that will automagically recreate a cck content type that i've developed by hand in an existing site?

2) i'd love to know more about interacting with cck via a drupal hooks and or per the module i mentioned in #1. That part seems to be really lacking from the manuals. So i'm anxiously waiting for that tutorial!

3) Finally a new question. In drupal 5, since you can add a cck field to any existing node type, when it comes time to theme the existing node type, how do you access the cck field in the node.tpl.php or standard theme functions for the original node? Since these cck fields are dynamic, how do the existing node types know anything about them to include them in their stock themes? Is that automagically handled by the cck field code itself via some hook or do we have to manually pass them in _phptemplater_variables to make them available? does it just use the standard cck field conventions?

I might be making more out of #3 than i need to but i'm assuming that there is a different way of handlind cck fields added to existing nodes versus cck fields that belong to a cck custom content type developed by scratch that are packaged as part of the custom content type. make sense?

Lots of questions in number 3. Basically, how do we incorporate cck fields that are *addons* to nodes into our themes?

thanks for the informative articles on the site

i love you nikki

i love you nikki

cck future

If you want the low down on the future of CCK, you shoul dlisten to the Lullabot podcast #30 with Karen Stevens, one of the current CCK maintainers. It's about now and ideas for the future.

Content type + CCK + Custom Module

I have create custom types in Drupal5 and see the module is set to "node".
Next I added CCK fields.
Finally, I created a custom module to create some pages for these types but I was really wondering how to marry custom types defined this way with a module that could capture the hook_type hooks. Is it just a matter of using node_type_info() to declare the types instead of drupal admin interface (or to override it what was created?). Once you do that must you provide hook_form, hook_insert, etc. or can you still rely on node to take care of that since it + CCK already knows how to put all the info in the db?

I'd love more info on this when you have time to share.

Wow! I've been a diehard

Wow! I've been a diehard custom module guy, pretty much from my beginning use of Drupal, and hadn't had the time to go back and read up on CCK... this sounds great... It could really speed up development times of all the repetitive tasks to get basic input and output for your node up to speed. Then it's just a matter of going back with the hooks to add all your functionality.

Cannot wait to rip the box open and take a look inside today! Thanks for pointing this out, I surely would have noticed sooner or later- but I wasn't exactly scanning the CCK pages since basically writing it off a year ago :)
---
prosebeforehos.com

:-) Let me know if you have

:-) Let me know if you have any questions or get into trouble; i'd be happy to provide what insight i have into it at this point.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.