Hi,
How would I go about building a complex CCK data type? The one I have in mind might be e.g. the different formats available for a "book" node:
Format Width Height Depth Weight ---------------------------------------------- Hardback 15cm 24cm 2cm 14oz Trade pback 14cm 22cm 1.5cm 10oz Paperback 10cm 15cm 1cm 6oz
Should I store each row as a flattened text field with delimiters e.g "Hardback&15&24&2&14", and let hook_widget() unflatten it prior to editing? Or can CCK store complex data types unflattened?
Given the form chunk to edit each row would be five input fields, can hook_widget() cope with making this whole block "multiple" easily enough? Would it need to be defined in form API as a multiple'd fieldset?
Cheers, J-P
For me it looks like a database relationshio between two tables, I think it's possible with CCK to establish realtionship with different content types, but is it the best way? I don't konw, someone knows a better way? :-)
Thank's for all
Pol Maresma / pol [ad] polnetwork.com PolNetwork.com / Serveis d'Internet Tempslliure.net / Bloc personal MSN: marolijo SKYPE: marolijo
-----Mensaje original----- De: support-bounces@drupal.org [mailto:support-bounces@drupal.org] En nombre de J-P Stacey Enviado el: dimecres, 4 / juliol / 2007 11:06 Para: support@drupal.org Asunto: [support] Complex CCK data type - multiple fields
Hi,
How would I go about building a complex CCK data type? The one I have in mind might be e.g. the different formats available for a "book" node:
Format Width Height Depth Weight
Hardback 15cm 24cm 2cm 14oz Trade pback 14cm 22cm 1.5cm 10oz Paperback 10cm 15cm 1cm 6oz
Should I store each row as a flattened text field with delimiters e.g "Hardback&15&24&2&14", and let hook_widget() unflatten it prior to editing? Or can CCK store complex data types unflattened?
Given the form chunk to edit each row would be five input fields, can hook_widget() cope with making this whole block "multiple" easily enough? Would it need to be defined in form API as a multiple'd fieldset?
Cheers, J-P -- [ Drupal support list | http://lists.drupal.org/ ]
No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.9.14/885 - Release Date: 03/07/2007 10:02
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.9.14/885 - Release Date: 03/07/2007 10:02
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"?
J-P Stacey wrote:
Hi,
How would I go about building a complex CCK data type? The one I have in mind might be e.g. the different formats available for a "book" node:
Format Width Height Depth Weight
Hardback 15cm 24cm 2cm 14oz Trade pback 14cm 22cm 1.5cm 10oz Paperback 10cm 15cm 1cm 6oz
Should I store each row as a flattened text field with delimiters e.g "Hardback&15&24&2&14", and let hook_widget() unflatten it prior to editing? Or can CCK store complex data types unflattened?
Given the form chunk to edit each row would be five input fields, can hook_widget() cope with making this whole block "multiple" easily enough? Would it need to be defined in form API as a multiple'd fieldset?
Cheers, J-P
I have another CCK question: how do I make fields show line breaks (hard returns)? I am geting everythign running on one line and I don't see anywhere to set the input format. Also I don't want the end users to have to put in html themselves.
Jean Gazis
On 7/5/07, Eric Mckenna eric.mckenna@gmail.com 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"?
J-P Stacey wrote:
Hi,
How would I go about building a complex CCK data type? The one I have in mind might be e.g. the different formats available for a "book" node:
Format Width Height Depth Weight ---------------------------------------------- Hardback 15cm 24cm 2cm 14oz Trade pback 14cm 22cm 1.5cm 10oz Paperback 10cm 15cm 1cm 6ozShould I store each row as a flattened text field with delimiters e.g "Hardback&15&24&2&14", and let hook_widget() unflatten it prior to editing? Or can CCK store complex data types unflattened?
Given the form chunk to edit each row would be five input fields, can hook_widget() cope with making this whole block "multiple" easily
enough?
Would it need to be defined in form API as a multiple'd fieldset?
Cheers, J-P
-- [ Drupal support list | http://lists.drupal.org/ ]
Hola Jean,
I have another CCK question:
It's better if you start a new thread for a new topic.
how do I make fields show line breaks (hard returns)? I am geting everythign running on one line and I don't see anywhere to set the input format. Also I don't want the end users to have to put in html themselves.
Change the default value in Data settings -> Text processing to -> Filtered text (user selects input format) ________________________________
Marco Antonio Villegas Vega ( º - º ) Ing. Informatica http://blog.pucp.edu.pe/marvil07
But where is "Data settings"? I'm using Drupal 5.1
The data type I want to have is recipes, and to avoid having a huge form with a zillion fields I wanted to just have one field for ingredients and have them input them as a list, but it is just one run-on text line. Same for directions.
Am I better off using a contributed recipes module? I think there is one.
On 7/5/07, Marco Antonio Villegas Vega marvil07@gmail.com wrote:
Hola Jean,
I have another CCK question:
It's better if you start a new thread for a new topic.
how do I make fields show line breaks (hard returns)? I am geting everythign running on one line and I don't see anywhere to set the input format. Also I don't want the end users to have to put in html themselves.
Change the default value in Data settings -> Text processing to -> Filtered text (user selects input format) ________________________________
Marco Antonio Villegas Vega( º - º ) Ing. Informatica http://blog.pucp.edu.pe/marvil07 -- [ Drupal support list | http://lists.drupal.org/ ]
Hi,
But where is "Data settings"? I'm using Drupal 5.1
- admin/content/types - edit on your type for recipes - manage fields - configure on your field to list
that's an option, another: - go to: admin/content/types/<nameOfYourType>/fields/<nameOfYourField>
now
Change the default value in Data settings -> Text processing to -> Filtered text (user selects input format)
About using a cotrib module.. I use a contrib module if it solve all my problem, but it's not always the best choice. Usually if you want something simple it's better to use CCK; and if you want something really customized maybe you're thinking in a new module :D
Cheers ________________________________
Marco Antonio Villegas Vega ( º - º ) Ing. Informatica http://blog.pucp.edu.pe/marvil07
Thank you very much! I found it and it worked, even for the test recipes I already entered.
On 7/10/07, Marco Antonio Villegas Vega marvil07@gmail.com wrote:
Hi,
But where is "Data settings"? I'm using Drupal 5.1
- admin/content/types
- edit on your type for recipes
- manage fields
- configure on your field to list
that's an option, another:
- go to: admin/content/types/<nameOfYourType>/fields/<nameOfYourField>
now
Change the default value in Data settings -> Text processing to -> Filtered text (user selects input format)
About using a cotrib module.. I use a contrib module if it solve all my problem, but it's not always the best choice. Usually if you want something simple it's better to use CCK; and if you want something really customized maybe you're thinking in a new module :D
Cheers ________________________________
Marco Antonio Villegas Vega( º - º ) Ing. Informatica http://blog.pucp.edu.pe/marvil07 -- [ Drupal support list | http://lists.drupal.org/ ]
Hi,
Thanks for your replies:
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.
I *think* my solution will need to *begin* with (at the very least):
module_field_settings('database columns')
returning an array of five columns, but I don't know if that's the right way of going about it or not.
Cheers, J-P
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.
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@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/ ]