Hello
How do I access the taxonomy_csv_vocabulary_import api function from my own custom module? I want to populate a few vocabularies when the module installs - I know where the files are and I want to call this :
$vocabulary_weeks = Array(
'source_content' => 'synonyms',
'source_choice' => 'path',
'destination_target' => 'existing',
'destination_vocabulary_id' => $vid,
'import_existing_items' => 'update_replace',
'relations_create_subrelations' => 0,
'relations_all_vocabularies' => '',
'hierarchy_level' => 2,
'result_stats' => 'result_stats',
'result_terms' => 'result_terms',
'result_level' => 'notices',
'result_type' => 'by_message',
'internal_cache' => 1,
'hierarchy_check' => 1,
'line_checks' => 1,
'utf8_check' => 1,
'delimiter' => ',',
'enclosure' => '"',
'file' => (object) array (
'filename' => 'synonyms.csv',
'filepath' => $module_path .'/synonyms.csv',
'filemime' => 'text/csv',
'source' => 'path',
'destination' => $module_path .'/synonyms.csv',
'filesize' => 1821,
'uid' => 1,
'status' => 0,
'timestamp' => time(),
'fid' => 7,
)
);
taxonomy_csv_vocabulary_import($vocabulary_weeks);
In my module installation file. The taxonomy_csv.api.inc has the following comment:
/**
* @file
* This API allows to use taxonomy_csv import functions from any other module.
*
* Functions sets:
* 1. Prepare and import a vocabulary : taxonomy_csv_vocabulary_import
Which suggests this is possible.
Comments
Comment #1
rukaya commentedI forgot to mention the error I get when I try and call it from my module (both the install file and the .module): Fatal error: Call to undefined function taxonomy_csv_vocabulary_import()
Comment #2
rukaya commentedIn case anyone else has this problem, adding the following code before attempting to access any taxonomy_csv function made it work:
$taxonomy_csv_path = drupal_get_path('module', 'taxonomy_csv');
require_once("$taxonomy_csv_path/taxonomy_csv.api.inc");
Comment #3
Daniel_KM commentedHi,
That's right.
Warning: from 4.7 release, variables have been renamed and simplified because there is now a taxonomy csv export form.
Sincerely,
Daniel Berthereau