views:

2011

answers:

3

Is there a way of creating a composite field that can have multiple values, with each value having another group of composite values?

E.g. we want to have this structure at the end:

  • Group 1 (unlimited number of groups)
    • Child field (unlimited children for each group)
    • Child field
    • ...
  • Group 2
    • Child field
    • Child field
    • ...
  • ...

Is this possible at all for a custom module that defines a CCK field? If so, can someone push me in the right direction?

+4  A: 

this is a very know and debated issue in the drupal world.

this feature is called cck "multigroup" and it looks it's pretty difficult to implement. there are a lot of posts in the drupal forum about this, i suggest you to start here:

http://drupal.org/node/494100

it's a kind of "hidden" feature in the cck module. looking in the module directory, you will find instructions here:

cck/modules/content_multigroup/README.txt

in the meantime you can try to deal with it using the flexifield module (but it's kinda hackish, i won't use it in production)

gpilotino
So there's really no way to do this without using alpha-quality code? Even if I were to write a custom CCK field type?
Karl
that's the mean truth. anyway, rumor has it, it looks that the latest cvs version of cck multigroup submodule is somewhat stable. there are too much issue to deal with if you want to reproduce such a behaviour yourself (think about the fact that even the cck developers were unable to accomplish this "simple" task !)
gpilotino
What conflicts will I run into when using CCK 3.x with other modules? Should I just go for it and see what happens?
Karl
So I installed CCK 3 with multigroups, and it really doesn't do what I need.I want multiple groups with a name, then each group contains multiple children.I found that I couldn't nest a multigroup inside of another multigroup. It just seems to be for grouping fields together, instead of creating a nested structure.
Karl
infact you can't. it's even stated in the flexifield project page: "Two features that flexifield has that multigroup doesn't have is the ability to have a multi-valued field inside a multi-valued flexifield"
gpilotino
+1  A: 

This issue is pretty old, but I just happened across it. I would think the way to handle it for now would be with a second cck type for the children, and the groups as a node_reference field. So you'd have:

MasterType

  • group field
    • unlimited per node
    • each one, a reference to a ChildType node

ChildType

  • child field
    • unlimited per node
sprugman
While that would totally work, it would be an absolute nightmare to try to train users to work this way.
Karl
It's definitely not ideal, but the [node relationships][1] module helps some. It provides create-and-add and search-and-add functionality in an overlay. [1] http://drupal.org/project/noderelationships
sprugman
A: 

I ended up creating my own "Cost/Product" CCK compound field based on this excellent tutorial with example modules: http://poplarware.com/es/articles/cck_field_module

I haven't figured out yet how to pull out a specific sub-field, such as cost, in Views. I only get the entire ": $" compound.

wgrunberg

related questions