CCK Node Reference w/ 2 nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
erichomanchuk@fosterinteractive.com's picture

Hi,

I have a problem where I have 2 node types, "Our Products" and "Competitors Products" which share a node reference with both content types selected on the reference. Currently I'm trying to get a view to work for displaying the the other types when adding or editing a specific node.

For example I have a node Titled "Our Product 1" I want to have a checkbox list with all "Competitors Products" on the add/edit action so I can choose which product is most identical to ours and the same for "Competitors Products" with a list of our products to reference.

I am using the same node reference field for these 2 node types so when I add/edit one of them I get all of nodes for both node types showing in my select boxes. I want to know the best way to accomplish this so that only the "Competitors Products" show up on "Our Products" and "Our Products" only show up on "Competitive Products". I am currently trying to do this by adding a view to the node reference, but am stuck on trying to use the node type as an argument for switching the filters.

Any help on this matter would be appreciated.

Comments

Simples.

niklp's picture

Create a new view and edit the "defaults" display - you don't need a "page" or anything else for this.

Set the style to unformatted, and the row style to fields.

Add an argument of "Node: Type". Set this to 404 if argument not present, basic validation and 404 if arg not present.

Add fields of Node Title and/or whatever else you want - this will determine how your results show up in the autocomplete widget (or whatever).

Because you're only targetting nodes of that type, you don't really need any filters or sort, unless that's your thing.

In your node reference, you then need (per instance of the field) to set a view (the one we created) and pass in an argument to the view - use the textual name of the type you want to reference.

This should be all you need to do! :)

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: