Updating Fields with Composite Data

liberatr@drupal.org's picture
public
liberatr@drupal.org - Tue, 2008-06-03 23:03

I have a custom module I inherited that implements its own CCK widgets to import videos, and the widget stores multiple columns in the database, but to the user, it all seems like one field.

I recently decided we needed to add a column to refer to the thumbnail, so I edited my 'database columns' operation in the hook_field_settings() function, and added a line in the hook_field() function, along with the logic I needed to fetch, display and validate the data.

If I add this field to a new content type, everything works as expected, I see the video, it's great. However, if I just try to add new data as the old content type, everything does not work so smoothly.

My question is: since CCK stores that data along with a table specific to the content type (in my case content_type_video), how do I write a script in the module.install file that will modify all the database rows as needed to make this change happen?

Are there other folks out there doing CCK widgets that need updating, and how does one handle the update?

Ryan Price
http://ryanpricemedia.com


Got an answer

liberatr@drupal.org's picture
liberatr@drupal.org - Fri, 2008-06-20 02:37

There is a function called content_fields() that will help you out with this if you ever need to write your own upgrade script for a module with custom widgets.
http://api.freestylesystems.co.uk/api/function/content_fields/5

Ryan Price
Florida Creatives