When using CCK, do we need to program in hook_load to load the data for the new fields

When using CCK, do we need to program in hook_load to load the data for the new fields

No, unless you need extra or custom data. The CCK automatically handles loading of data for the fields created via the CCK. In general the CCK does a good job loading its data, however there are times where you might want additional data that is not automatically loaded. A good example of needing extra data is when using the imagefield. The standard load of imagefield includes a ‘#value’ var that has a fully marked up img tag. However, if you only want the url, say to pass to a imagecache call, you need to do some extra work as it is not automatically loaded. To get the raw image path you take the fid that the imagefield auto load does provde and query the files table to get the filepath. (You could also do a regex on the #view value to get the path) One tricky problem with using the node_load or nodeapi hooks is that when they are called, only the base node table information has been added to the $node variable. The CCK data is loaded afterwards, so for modifications that require data from the CCK you will have to manually load the data or find another work around.

Related Posts

Introduction to fields in Drupal 7

Tom McCracken
Read more

Drupal Tutorial: List Fields

Tom McCracken
Read more

Adding fields in Drupal 7

Tom McCracken
Read more

A Simple Entity Data API for Module Builders

Tom McCracken
Read more

Using Image Fields in Drupal 7

Tom McCracken
Read more

Understanding Drupal 7 core fields structure

Tom McCracken
Read more