Closed (fixed)
Project:
Taxonomy CSV import/export
Version:
7.x-4.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Jul 2010 at 03:59 UTC
Updated:
8 Jul 2010 at 08:28 UTC
Hi
I am trying to use taxonomy api to import terms.
I am using
$csv_lines = 'Europe, France, Paris';
$result = taxonomy_csv_vocabulary_import(
array(
'source_choice' => 'text',
'text' => $csv_lines,
'import_format' => 'tree_structure',
'existing_items' => 'update_replace',
));
First
I receive an error Warning: is_dir(): Unable to find the wrapper "public" - did you forget to enable it when you configured PHP? in file_prepare_directory() (line 402 of C:\xampp\htdocs\drupaltrial\includes\file.inc).
So how can i solve this problem.
Second i want to import in an existing vocabulary. How can i define vid in this code?
Comments
Comment #1
Daniel_KM commentedHi,
Thanks to try 7.x release.
Example doesn't contain all variables. You can add vocabulary id as indicated line 135 (XXXX here) :
For xampp or php error, i can't answer today, because Windows is not installed on my computer. I'll try wednesday.
Sincerely,
Daniel Berthereau
Knowledge manager
Comment #2
zulfierken commentedHi I tried again wit your code and i have an error:
Fatal error: Call to undefined function taxonomy_get_vocabularies() in C:\xampp\htdocs\drupaltrial\sites\all\modules\taxonomy_csv\taxonomy_csv.api.inc on line 377
And also the public error continue to show.
I checked my taxonomy module and it is running fine. I tried to import with your import form it worked fine. Then why didnt the code work?
$taxonomy_csv_path = drupal_get_path('module', 'taxonomy_csv');
require_once("$taxonomy_csv_path/taxonomy_csv.api.inc");
$csv_lines = 'Europe, France, Paris';
$result = taxonomy_csv_vocabulary_import(
array(
'source_choice' => 'text',
'text' => $csv_lines,
'import_format' => 'tree_structure',
'existing_items' => 'update_replace',
'vocabulary_target' => 'existing',
'vocabulary_id' => 2,
));
This is what i put in my module and call it once the module run :(
Comment #3
Daniel_KM commentedHi,
Apparently, Drupal module "Taxonomy" is not included, because taxonomy_get_vocabularies() is a function of this core module. Perhaps it's not enabled. So you should enable it in module pane.
Another way to do it cleaner is to to add dependencies in your my_module.info file :
The "(7.x-4.11)" is not needed, but next release 7.x-5 will change structure of module and eventually break compatibility.
If you don't want to enable module or to add dependencies, for example if you directly copy taxonomy_csv.api.inc in your module, you need to invoke taxonomy core module as taxonomy_csv module :
Sincerely,
Daniel Berthereau
Knowledge manager
Comment #4
Daniel_KM commentedSee my updated answer above.