I've created a few custom content-types using CCK to migrate my current site, which is a lot of custom code to Drupal. After creating the CCK types, I imported all my data by directly inserting data into the content_type_* tables and content_field_* tables. I imported the data using a perl script and did not touch any aspect of Drupal's functions itself.

I'm having a problem with how CCK's edit form and how it deals with nodereference fields. The problem I'm having is that any field that's a value, rather than a nodereference shows up in my edit form just fine. THe node-reference fields show up as drop-down lists (as I would expect). I also have a user-reference field, which is multi-select. However, these nodereference fields (and the userreference field) do NOT have the correct nid/uid selected, even though the value is correct in the database.

If I select the item in the drop-down, and in the multi-select list and submit the form, then re-edit the entry the appropriate items are selected.

I'm assuming that I'm missing an entry in some table or location, and can't figure out where. I've got my content-type's in the node table with the type set to the appropriate type. I've got the node-revision entry correct. i've got the content_type_typename table with the appropriate data, and the fields all correct. So where does the nodereference mapping happen that I'm missing?

[Apologies if this is insufficient information, but I'm just not sure what more to add without being too verbose]

thanks for any suggestions

Comments

cybertoast’s picture

I just rebuilt the teasers (using retease), and this solved the problem. I now have all the nodereferences working properly. But I don't understand why. What database change takes place to make the nodereference and userreference work correctly upon re-creating the teasers?
Obviously I don't understand CCK very well, but this seems like it would be a very straight-forward thing, and I just don't get it!

kevin hankens’s picture

Did you ever figure out what was fixing the nodereference? I'm doing a migration at the moment and running into the same problem. It seems like it *should* only require the one relational table. I can't find anything in the CCK code that would suggest otherwise.

Any help would be greatly appreciated!

kevin hankens’s picture

To anyone else who stumbles upon this problem, the node reference fields won't be populated in node/x/edit until you clear the cache. Use the following function for each node that you create outside of drupal:

cache_clear_all('content:'. $node->nid .':'. $node->vid, 'cache_content');

I found the solution in the following forum: http://drupal.org/node/133705

Note, the solution is in the comments. The post is a great CCK reference for anyone doing a drupal migration.

Good luck!!