Add support for content_taxonomy
rconstantine - April 15, 2009 - 17:29
| Project: | Node import |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | rconstantine |
| Status: | needs review |
Description
I'm working on this. I think I've done the inc file OK, but I'm waiting on another internal group for some test data. That could be soon, or it could be a couple of weeks. Once I've tested, I'll post the inc file here.

#1
Great. If you need any help with it, ask here.
#2
My catalog taxonomy isn't importing; definitely interested in what you come up with.
#3
Maybe you could post the .inc even if it is untested?
#4
I am very interested in this feature too and would love to do some testing...
#5
I would also love to get my hands on this / help with testing. Patiently awaiting the inc file -- any updates?
#6
Subscribing.
I have used the latest -dev -release, with checkboxes as taxonomy, with the following import results:
- If the field is set as required, the import will give "Illegal choice in field_name element."
- set to not required, the import works but only the first value is imported (tried with only 2 items).
#7
@ #6, I have no idea what you're talking about.
All - I've got test data and I think I'm close. It's really a small module. I wonder whether it is complete for all cases. Anyway, I have a bug. I'll attach what I have so far and below is the 'preview' on step 7 of 8 with the error I get. The output looks fine to me, so I wonder what is wrong.
Put the attached file in 'supported/cck'
#8
#9
OK. I figured out what to do. I just finished the case for using the content_taxonomy_tree widget. I'm not sure whether I'll have time to do the others, so I'll post what I do here regardless. One last thing I want to do is convert a portion of the function into a recursive function so as to handle any depth of tree. Presently, since my test data only has two levels, that's all I coded for. Expect a post here in another couple of days with the inc file as I have it.
#10
I already have 9000 nodes in csv file. Every node has assigned taxonomy term. Is it possible with this feature to import nodes with already assigned taxonomy terms ?
#11
I'm fairly certain that the regular operation of node_import doesn't allow adding data to existing nodes if that's what you're asking.
Anyway, here is the new file...
Like I said, work may need to be done for other widgets. See my comments in the file itself.
#12
#13
So can I just add the content_taxonomy.inc to the module? Or what do I do with it if I want to test it? Node Import works great but like others being able to import content_taxonomy fields is critical to me.
Thanks,
V
#14
So to answer my own question in case any other newbies are wondering: Put the .inc file in sites\all\modules\node_import\supported
Then I ran the update.php - just to make sure and it worked great!
Thanks for writing this code! It saved us about 2 months worth of data entry.
#15
Sorry, I thought I mentioned where to place it. I actually put mine in sites\all\modules\node_import\supported\cck, but it doesn't really matter I don't think. I'm not sure which is better in this case. I figure the maintainer can decide.
@VeeLin - can you tell us which content_taxonomy widget your content type is using? I have just two cases defined - first is the special case where you are using the tree widget - second is for all other widgets. I was assuming that the second might not work for all widgets and that we'd need to add support for them later. So if anyone else tests this, please let us know what widget you're using. For all I know, the second case does work for all of the other widgets.
#16
I'm not 100% sure what you mean by widget. I am using a Content Taxonomy Field in the custom content type. The vocabulary does NOT have hierarchy. It is a one level vocabulary. I'm also importing another vocabulary which adds coma separated vocabulary terms to the node. This is also through a content taxonomy field but this taxonomy adds new terms to the vocabulary while the other does not allow addition of terms.
I hope this answers your question - if not I'll try to elaborate.
Kind Regards,
V
#17
By widget, I mean the second drop down you use when adding a new field. The first column is the Human-readable name, the second is the machine-name, the third is the cck field type, the fourth is the widget. Options for a content taxonomy field are: Autocomplete (Freetagging), Checkboxes/Radios, Select List, and if you have it enabled somewhere, Tree. I don't recall whether that last one is standard or an add-on module.
Anyway, that should answer your question.
#18
Can't get this addon working with content_taxonomy_options (Content Taxonomy Checkboxes)
The data displays fine when I put some print array -codebits inside the previously posted code. I can't find yet why it doesn't save the correct data.My taxonomy field is set as required, so it selects only the first one, even though I have 2-3 in every row. And by the first one I mean, the first listed taxonomy term available, not first of the imported ones.
#19
Like I said, support for the other widgets might need to be added. Sounds like it does. Anyone want to pitch in and help? You would just add a new 'else if' to the content_taxonomy_node_import_values_alter function.
It would start with:
if ($fieldinfo['widget']['type'] == 'content_taxonomy_options') {#20
OK - so to answer the question a few back I am using a few widgets sucessfully:
Autocomplete (Freetagging): works in most cases. There were a few terms it had an isssue with but adding them to the vocabulary before import fixed this - wired bug but can be overcome. one of the terms was "autoloaded".
checkboxes/Radial buttons: From this you can only select one term. No issues but your formatting must be bang on - ensure there are no leading or ending spaces.
Did not use select list widget.
My import is complete. Thank you for all your help.
Also it was almost 5000 nodes and ran for about 3.5 hours with no issues.
Cheers,
V
#21
Thanks for the info VeeLin! Now if we can get some help filling in the blanks, we'll have a complete patch.
I noticed the ending spaces problem too.
Looks like I'll have to test the select list widget this week, so I'll add code if needed.
#22
hmm. we've installed this (and have run update.php) and I'm a little confused. our test content type has three content_taxonomy fields:
State
Region
Resort
All three of those use Autocomplete (Free Tagging) widgets. State and Region are set so that the user can't add new tags, Resort is set so new tags can be added.
On Step 4 - the node_import Map File Columns page - we see the Resort selection as a pulldown menu showing the column headers for the imported CSV file. We don't see anything for mapping State, and for Region (which as of right now doesn't have a corresponding column in the CSV file, we see a multi-select field showing the imported files column headers, rather than a pulldown. I'm not sure why the inconsistency in the types of selection widgets here, but that's what we're getting.
In any case, since "Resort" seems to work normally, we map it to the "Resort" column in the imported file, and we go ahead with the import. The resulting nodes don't have the Resort Content Taxonomy field filled in, and we have to do them manually. By the way, the resort names already exist in the Resort vocabulary, so we're not trying to add them. Any ideas?
#23
quick update on my previous post: this module wasn't working because for some reason my ftp client didn't give it the right permissions. so it wasn't being loaded. In any case, I fixed that and the State content_taxonomy field works. However, the Resort Name content_taxonomy field doesn't work. It's really weird - as far as I can tell there's no difference between the two fields. (I've set Resorts so that users cannot add terms, which is how State is set up), and there are matching resort names in the Vocabulary, imported from the same spreadsheet using the Taxonomy Import module. So I know there are no spelling differences or anything like that.
any ideas why some fields would work but others wouldn't?
#24
i don't want to ignore you, but i don't have any ideas. if you don't have existing nodes yet, you can try deleting the offending field and rebuilding it.
#25
subscribe
#26
@rconstantine: that seems to have done the trick. thanks.
#27
I tried the file from #11 and importing data into content_taxonomy fields worked! Thanks for adding support for content_taxonomy.
#28
Subscribing...
Great work done here... :)
#29
#11 Works fine for me.
@rconstantine: thanks a lot for the very useful code.
#30
@rconstantine
hello, big thanks for .inc for taxonomy_content, but it not working for tree widget in my case (i'm make import by change it to select list widget)
i have big, multi parent vocabulary, with 7 level depth, and on step 7 i have error mesage from #7.
But big thanks anyway.
#31
a big thanks indeed!!
#32
Thanks for this, I was looking at a solid couple days of input - this patch was perfect.
#33
Thanks, the patch from #11 worked for me too and saved me a lot of time.
As others have pointed out, all terms need to exist before they get added, otherwise it won't work. Apart from this, it works well.
#34
yeah, the patch from #11 is working for me as well. however, it seems content taxonomy import is case sensitive... ?
maybe there should be an option to choose between case sensitive and insensitive ?
anyway, this is a very useful module nonetheless.thanx