Hello,

When importing a CSV file into a custom node type (CCK) which has a Node Reference as one field, then it requires that node to have a universally unique node title (i.e. the node must have a unique title for all nodes). This is problematic for if you have two of the same node titles, which are attached to nodes of different types.

As an example:

----------------------
Node/1
-> Type: type_1
* Title: XYZ
* Body: ...
----------------------

----------------------
Node/2
-> Type: type_2
* Title: XYZ
* Body: ...
----------------------

When importing the CSV file into a different node of a different type once again, e.g. type_3 which references (say) type_2... it comes up with this error message:
type_2: : this post can't be referenced.

Which, I am guessing, must mean that it is searching using node title when loading up Node References.... and returns the first node. (this works if the node ref happens to be type_1... as the node is earlier in search results).

Therefore, in order to get it working we must have universal node titles.... not ideal! I'm considering changing my knowledge-architecture so that I don't have duplicate titles (as I don't really need to do it the way that I am currently doing it), but in other circumstances the reliance on node title isn't necessary.

My proposal for (partially) fixing this bug is actually by restricting the node reference to search the specific type being referenced only (e.g. searching through "type_2" only, rather than all types). If I get a chance then I'll look at this myself, but if anybody else gets a chance before I do then it'll be appreciated :-) I've also noticed that it is a similar problem in other parts of the module (i.e. the reliance on title, but this is slightly more specific to types... and I hope that by specifying particular node types to search through will eliminate some problems when using node title).

This is the first issue I've created relating to Drupal, and I'm quite new to Drupal itself. But I'll help where and when I can :-)

Thanks ever so much! I hope all is well with you all.

Daniel

-----
Other information:
-----
* Drupal version: 6.12
* PHP Version: 5.2.6
* MySQL Version: 14.12 Distrib 5.0.75
* CCK Version: 6.x-2.4

Comments

david lesieur’s picture

Title: Node Reference » Importing Node Reference fields relies on unique node titles (not always practical)

More descriptive title for this issue.

cyberwolf’s picture

Subscribing.

cyberwolf’s picture

Using _nodereference_potential_references (although meant to be a private function currently) or a similar function might be a solution.

blue56’s picture

I can confirm this issue. I also argee on the solution proposal.

blue56’s picture

Title: Importing Node Reference fields relies on unique node titles (not always practical) » Node Import. Node reference. Trying to fix "this post can't be referenced"

It sounds like a good idea to use this function because it is part for the node reference module and proberly more stable. I think node_import_check_node_reference function in node_import.inc should be rewritten, But are there other places?

Kind regards
Jacob

blue56’s picture

Title: Node Import. Node reference. Trying to fix "this post can't be referenced" » Importing Node Reference fields relies on unique node titles (not always practical)
cyberwolf’s picture

StatusFileSize
new5.96 KB

Attaching a patch. It does the job but probably can use a lot of cleanup.

cyberwolf’s picture

StatusFileSize
new4.28 KB

Previous patch contained some files of my IDE, so reuploading without those files.

kbk’s picture

Status: Needs review » Active
kbk’s picture

Status: Active » Needs review
flaviovs’s picture

Version: 6.x-1.0-rc4 » 6.x-1.x-dev
Status: Active » Needs review

Patch #8 fixed the issue to me. NB: I'm using 1.x-dev.

mtcs’s picture

Patch #8 is also working for me.
See my other issue about case sensitivity: #1308600: Case sensitivity in node reference titles