[support] Complex CCK data type - multiple fields
yched.drupal at free.fr
yched.drupal at free.fr
Sat Jul 14 00:47:53 UTC 2007
the field.php file in your cck folder provides detailed API documentation which
will probably save you lots of trial and errors...
On the per field / per content type tables, the rule is the following :
- fields that are shared across multiple content types are stored in per-field
tables
- fields that are set to allow multiple values are stored in per-field tables
- other fields (not shared, not multpiple, are grouped in a table for the
content type.
Search on lullabot.com for an excellent article by Robert Douglass explaining
that in detail.
Yched
Selon jp.stacey at torchbox.com:
> Hi,
>
> um, returning late to this party: I worked out how to enter and save
> complex CCK data types. As the drupal.org tutorials seem a bit opaque on
> this I'm posting it here FYI.
>
> Two of the module hooks for defining the CCK fields need to work in
> tandem:
>
> hook_field_settings('database columns', $field) needs to return
> an array for setting up the db columns, with keys for all
> the sub-data elements:
>
> return array(
> 'descr' => array('type' => 'varchar', ...),
> 'depth' => array('type' => 'decimal', ...),
> 'width' => array('type' => 'decimal', ...),
> 'height' => array('type' => 'decimal', ...),
> );
>
> hook_widget('form', ... ) needs to return a chunk of form
> API with fields whose names match the keys in the above:
>
> $form[$field['field_name']][$delta] = array(
> '#type' => 'fieldset',
> 'descr' => array(...),
> 'depth' => array(...),
> 'width' => array(...),
> 'height' => array(...),
> );
>
> CCK creates the database tables for you: I can't work out what prompts it
> to create a new table and what just makes it save the values to
> content_type_foo, though.
>
> If you've read this far, then cheers,
> J-P
>
> > Eric Mckenna wrote:
> > > Can you explain a little more. I'm having trouble making out what you
> > > are trying to do.
> > > Why does adding these fields to your "book" node not work?
> > > And what do you mean by a "complex CCK data type"?
> >
> > By "complex" I mean having structured data within each occurrence of the
> > field. For example, if my books were available in different languages,
> > then that wouldn't be complex because each CCK field would be just a
> > single dropdown:
> >
> > Available in:
> > -------------
> > English
> > German
> > Spanish
> >
> > Each occurrence of the book's format, however, has five bits of data in
> > it: paperback/hardback, weight in ounces and three dimensions in
> > centimetres. So I can't just use one of the out-of-the-box CCK field types
> > and am not quite sure how to build a field type to cope with it.
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
More information about the support
mailing list