Drupal Custom CCK field with multiple child fields

跟風遠走 提交于 2019-12-05 01:18:15

问题


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?


回答1:


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
Edit: Ongoing work on the multigroup module has moved to the experimental CCK 3.0 branch.

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)




回答2:


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.




回答3:


For Drupal 7+, you probably want to check out the Field collection module, or Field group if multiples aren't necessary.




回答4:


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


来源:https://stackoverflow.com/questions/1640534/drupal-custom-cck-field-with-multiple-child-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!