开发者

CCK in input form, but not in node structure

I have a content type (Witl) that the user creates. On the creation form, the user selects an option out of a list of nodes that's generated from a view (VOut). Right now I store that option as a node reference on Witl.

I need to restructure things around, so that this node reference isn't stored on Witl itself, instead eventually stored as a node reference on another node. However the user can only create Witl content types. This means that I have to figure out a way to present that view (the selection list) to the user on Witl, yet not save it on Withl at all. Can it be done? Is th开发者_Go百科ere a way to use one content type creation form only as a way to present the view, yet not store the data on this content type?


Yes, this can be done.

Instead of creating the field on the content type Witl, implement hook_form_alter() to add the field dynamically to the content creation form. Then, implement hook_nodeapi() to save this value somewhere, after the form is submitted.

I'm not sure if it's the best way, though.


Is it really important that the reference is not stored in the Witl node? There are several modules that try to address the problem of creating and displaying bi-directional relationships between nodes, but as far as I know, none of them save the reference only in the referenced node.

Suppose you have two nodes, node A (type: Witl) and node B (type: other), and you need to do something with the reference from B to A. This is your situation, right?

The Corresponding Node References module takes the 'easy' approach and will take the reference in A to B and duplicate it as a reference in B to A.

Other modules, like Node Relationships and Reverse Node Reference argue that databases should not contain duplicate data and try to resolve the relationship in A to B when looking at node B.

If it is indeed a must that the reference, when added in A, is only stored in B, then personally, I would take the code from Corresponding Node References as a basis for a custom module.


I believe its possible to do this using the following module

http://drupal.org/project/nodereference_url

Here is a tutorial of the module:

http://mustardseedmedia.com/podcast/episode37

This tutorial might confuse you a bit so I would recommend you read the documentation for the module first.

Basically, what this module will do is allow you to link a VOut to a Witl. Right now as you explained, a Witl links to a VOut. But after using the nodereference URL module you will be able to have a node reference field within VOut that links back to a Witl.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜