在 Drupal 6 中,当创建引用节点类型的新节点时,如何在节点上自动创建 CCK 字段?
我正在使用 Drupal 6 和 Views 2,以及 CCK、面板和节点关系。 (到目前为止)
我定义了两种基本内容类型:
- 用户配置文件(使用内容配置文件模块)
- 产品
这些内容类型中的每一种都具有对其他两种内容类型(层级和佣金)的节点引用:
- 用户配置文件内容引用“层级”内容
- 产品内容参考“佣金类别”内容
每个可能有 5-10 个,每个用户/产品最多 100 个。
添加佣金类别时,需要为每个当前现有的层节点添加美元值。
添加层级节点时,需要将该层级的美元值添加到每个当前现有的佣金类别节点。
期望的效果是具有“员工”角色的用户可以管理用户级别和产品类别。
当用户查看显示为其等级和佣金类别组合的产品时,他们将看到一个值。
例如:
类别 A =>第 1 级 ($100)、第 2 级 ($200)、第 3 级 ($300)
B 类 =>第 1 级(120 美元)、第 2 级(250 美元)、第 3 级(300 美元)
有办法按照我的建议进行吗?或者我是否需要尝试完全不同的方法才能达到预期的效果?
I'm using Drupal 6 and Views 2, along with CCK, Panels and Node Relationships. (so far)
I have two basic content types defined:
- User Profile (using Content Profile module)
- Product
Each of these content types has a node reference to two other content types, Tier and Commission:
- User Profile content references "Tier" content
- Product content references "Commission Category" content
There may be 5-10 of each of these, and up to 100 of each of users/products.
When a Commission Category is added, dollar values need to be added for each currently existing Tier node.
When a Tier node is added, dollar values for this Tier need to be added to each currently existing Commission Category node.
The desired effect is that users with a "staff" role can administrate both Tiers of users and Categories of Product.
Users will see a value when they view a product that is displayed as a combination of both their Tier and the Commission Category.
For Example:
Category A => Tier 1 ($100), Tier 2 ($200), Tier 3 ($300)
Category B => Tier 1 ($120), Tier 2 ($250), Tier 3 ($300)
Is there a way to do what I'm suggesting? or do I need to try a different approach altogether to achieve the desired effect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您还希望以后能够从“层级”节点页面或“佣金类别”节点页面编辑这些金额。
为了使这些值更易于管理,您可能需要创建另一个内容类型(例如,称为佣金),它引用层级和佣金类别,并保存美元值。
然后我要做的是使用 hook_form_alter() ,以便在 Tier 表单中为每个佣金类别添加一个输入字段。这样,每当您添加新层(或编辑现有层)时,您都可以立即更新所有这些值。使用 hook_nodeapi() 插入/更新所有相应的 Commission 节点。
然后,您可以对佣金类别表单执行相同的操作,但方向相反。
如果您期望有大量的层或类别,这可能是一项繁重的操作,但否则应该没问题,因为我假设您不会频繁地更改这些值。
I assume that you also want to be able to later edit those amounts from either the Tier node page or the Commission Category node page.
To make those values easier to manage, you will probably need to create another content type (called Commission for example) which references a Tier and a Commission Category, and holds a dollar value.
What I would do then is to use hook_form_alter() so that in the Tier form, an input field is added for each Commission Category. That way, whenever you add a new Tier (or edit an existing one), you can update all those values at once. Use hook_nodeapi() to insert/update all of the corresponding Commission nodes.
Then you can do the same thing for the Commission Category form, but in the other direction.
If you expect to have a large number of tiers or categories, this may be a heavy operation, but otherwise it should be fine since I'm assuming you wouldn't be changing these values that frequently.