在 Drupal 中使用单个自定义表单创建多个 CCK 节点 [英] Create multiple CCK nodes with single custom form in Drupal
问题描述
我需要一个允许同时创建多个相关节点的表单.所有节点都涉及 CCK 字段.
I need a form which will allow creation of several related nodes at the same time. All of the nodes involve CCK fields.
我想尽可能多地/实用地使用 CCK 的内置验证、提交、输入小部件和安全功能.
I would like to use as much of CCK's built-in validation, submission, input widget, and security functionality as possible/practical.
在 Drupal 6 中实现这一目标的最佳方法是什么?是否有最佳做法"或文档?
What is the best way to accomplish this in Drupal 6? Are there 'best practices' or docs anywhere?
这是我可以看到的 3 种可能性.我希望得到有关这些方法是否可行的反馈,或者是否有更好的选择.
Here are 3 possibilities I can see. I would love feedback on whether any of these would work, or if there are even better options.
- 从内容类型 foo 的标准节点创建表单开始.
- 通过为内容类型栏添加字段来修改表单,使用钩子 form_alter [可以直接插入内容类型栏的 cck 小部件吗?]
- 使用自定义提交处理程序在提交表单时创建 bar 类型的节点[可以调用标准的 cck 处理程序吗?还是我需要手动"构建节点对象,进行自己的验证,然后使用 node_save?]
- 创建一个新的自定义表单,将相关内容类型的普通"节点创建表单连接起来.
- 然后根据需要使用钩子 form_alter 修改表单.
- 允许标准 cck 提交处理程序来完成创建节点的工作.
- 从头开始创建自定义表单
- 在我自己的提交处理程序中创建节点,使用节点准备、节点保存等.
如果找到关于重新使用标准节点创建表单的文档,但是没有提到同时创建多个节点.
If found documentation on re-using the standard node creation form, but creating multiple nodes at the same time is not mentioned.
advomatic 网站上的一篇帖子中记录了使用 hook nodeapi 和 hook form_alter,但特定方法 descrube 似乎需要使用虚拟"字段污染其中一种内容类型.
Using hook nodeapi and hook form_alter is documented in a post on advomatic's site, but the particular method descrube seems to require polluting one of the content types with 'dummy' fields.
非常感谢您的帮助!
推荐答案
advomatic 家伙为此发布了一个很好的解决方案.
The advomatic guys posted a nice solution to this.
http://www.advomatic.com/blogs/jonathan-delaigle/multiple-nodes-single-node-submission
这篇关于在 Drupal 中使用单个自定义表单创建多个 CCK 节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!