2

I have added some taxanomy vocabulary with terms in my local development server which I need in some modules. I want to get these vocabularies with terms auto inserted when ever I install these modules where I have used them. Is there a way I write some code in drupal module which inserts the taxonomy vocabularies and terms when ever I install the module.

Thanks for your suggestions.

3

Rather than writing code, I use the Taxonomy CSV module. It allows you to export and import taxonomy as CSV files. You can use the module's user interface or do it by command line with Drush to speed things up even more.

Initial configuration can be a little tricky, but it's able to preserve tree hierarchies and order, etc. so a bit of complexity is to be expected.

| improve this answer | |
  • 1
    Thanks Patrick, I need to add 5-6 terms in a single vocabulary so using a module for this will be complex as per requirements. – Umar Apr 30 '12 at 11:01
  • 1
    +1 CSV import is much more efficient than coding a lot of the time. @Umar If this won't work for you check out the taxonomy_vocabulary_save() and taxonomy_term_save() functions, they should give you a good starting point. – Clive Apr 30 '12 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.