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

Robrecht Jacques - April 16, 2009 - 06:58

Great. If you need any help with it, ask here.

#2

GreyHawk - April 17, 2009 - 19:04

My catalog taxonomy isn't importing; definitely interested in what you come up with.

#3

Robrecht Jacques - April 21, 2009 - 18:01

Maybe you could post the .inc even if it is untested?

#4

criz - May 16, 2009 - 19:30

I am very interested in this feature too and would love to do some testing...

#5

epicsauce - May 21, 2009 - 02:00

I would also love to get my hands on this / help with testing. Patiently awaiting the inc file -- any updates?

#6

repolainen - May 21, 2009 - 12:19

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

rconstantine - May 28, 2009 - 22:04

@ #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'

Record 1:

---------here is the error--------------->Building and Department field is required.

values = Array
(
[created] =>
[node_import_build_mode] => 1
[title] => ant
[cck:field_accounting_unit:value] => Array
(
[0] => 45669000
)

[cck:field_ip_address:value] => Array
(
[0] => 10.30.8.101
)

[cck:field_duplex:value] => Array
(
[0] => Duplex
)

[cck:field_asset_status:value] =>
[cck:field_serial:value] => Array
(
[0] => USQA045540
)

[cck:field_device:value] => Array
(
[0] => HP LaserJet 4050N
)

[cck:field_lawson_req_loc:value] => Array
(
[0] => 53ALR
)

[cck:field_queue_name:value] => Array
(
[0] => ALRAD01Q
)

[cck:field_build_dept:value] => Array
(
[0] => An address here that I'm changing for posting purposes <------------------------------these are the taxonomy terms
[1] => A department here that I'm changing for posting purposes <--------------------------they start as strings, so must be converted
)

[cck:field_floor:value] => Array
(
[0] => 1
)

[cck:field_status:value] => Array
(
[0] => Deployed
)

[cck:field_company_num:value] => Array
(
[0] => 180
)

[type] => printer
[cck:field_num_trays:value] => Array
(
[0] => 3
)

[log] => Imported with node_import.
[uid] => 1
[revision] => 0
[promote] => 0
[status] => 1
[sticky] => 0
[path] =>
[name] => admin
[taxonomy] => Array
(
)

[field_accounting_unit] => Array
(
[0] => Array
(
[value] => 45669000
)

)

[field_ip_address] => Array
(
[0] => Array
(
[value] => 10.30.8.101
)

)

[field_duplex] => Array
(
[value] => Array
(
[Duplex] => Duplex
)

)

[field_asset_status] => Array
(
[value] => Array
(
)

)

[field_serial] => Array
(
[0] => Array
(
[value] => USQA045540
)

)

[field_device] => Array
(
[0] => Array
(
[value] => 45
)

)

[field_lawson_req_loc] => Array
(
[0] => Array
(
[value] => 224
)

)

[field_queue_name] => Array
(
[0] => Array
(
[value] => 623
)

)

[field_build_dept] => Array
(
[0] => Array
(
[value] => 2218 <----------------------------here are the terms converted to TIDs
)

[1] => Array
(
[value] => 2221 <----------------------------they look like they aren't empty, so why the error message?????
)

)

[field_floor] => Array
(
[0] => Array
(
[value] => 1
)

)

[field_status] => Array
(
[value] => Array
(
[Deployed] => Deployed
)

)

[field_company_num] => Array
(
[value] => Array
(
[180] => 180
)

)

[field_num_trays] => Array
(
[0] => Array
(
[value] => 3
)

)

[op] => Preview
)

AttachmentSize
content_taxonomy.zip 718 bytes

#8

rconstantine - May 28, 2009 - 22:02
Version:6.x-1.0-rc4» 6.x-1.x-dev

#9

rconstantine - June 1, 2009 - 21:17

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

bartekfly - June 2, 2009 - 12:52

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

rconstantine - June 2, 2009 - 18:32

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.

AttachmentSize
content_taxonomy.zip 1.38 KB

#12

rconstantine - June 2, 2009 - 18:32
Status:active» needs review

#13

VeeLin - June 4, 2009 - 21:10

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

VeeLin - June 4, 2009 - 22:09

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

rconstantine - June 5, 2009 - 20:02

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

VeeLin - June 8, 2009 - 16:47

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

rconstantine - June 9, 2009 - 01:56

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

repolainen - June 14, 2009 - 23:02

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

rconstantine - June 15, 2009 - 16:15

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

VeeLin - June 24, 2009 - 15:27

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

rconstantine - July 13, 2009 - 19:10

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

friolator - August 4, 2009 - 16:44

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

friolator - August 4, 2009 - 22:52

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

rconstantine - August 9, 2009 - 02:32

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

ianchan - August 9, 2009 - 06:52

subscribe

#26

friolator - August 9, 2009 - 15:59

@rconstantine: that seems to have done the trick. thanks.

#27

ianchan - August 11, 2009 - 18:37

I tried the file from #11 and importing data into content_taxonomy fields worked! Thanks for adding support for content_taxonomy.

#28

paganwinter - September 17, 2009 - 16:29

Subscribing...
Great work done here... :)

#29

gavranha - September 22, 2009 - 13:31

#11 Works fine for me.
@rconstantine: thanks a lot for the very useful code.

#30

temp - September 22, 2009 - 18:28

@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

regmanabq - October 22, 2009 - 07:03

a big thanks indeed!!

#32

thadwheeler - November 2, 2009 - 21:39

Thanks for this, I was looking at a solid couple days of input - this patch was perfect.

#33

Bodo Maass - November 6, 2009 - 12:29

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

30equals - November 24, 2009 - 10:40

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

 
 

Drupal is a registered trademark of Dries Buytaert.