This patch only create a specific hook for taxonomy_export: hook_taxonomy_export_process(). There are 4 operations in this hook:

  • export vocabulary
  • export terms
  • import vocabulary
  • import term

Exemple of implementation of this hook:

/**
* Implementation of hook_taxonomy_export_process().
* Module taxonomy_export
*/
function mymodule_taxonomy_export_process(&$edit, $op) {
  switch ($op) {

    // $edit -> vocabulary object
    case 'export vocabulary':
      // Some operations with $edit->vid...
      // ...
      $edit->new_attribute = mymodule_get_vid_attribute($edit->vid);
      break;

    // $edit -> array of term objects (tree)
    case 'export terms':
      if (! empty($edit)) {
          foreach ($edit as &$term) {
            $term->my_attribute = mymodule_get_term_attribute($term->tid);
          }
        }
      }
      break;

    // $edit -> vocabulary array
    case 'import vocabulary':
      if (! empty($edit['new_attribute'])) {
        mymodule_save_vid_attribute($edit['vid'], $edit['new_attribute']);
      }
      break;

    // $edit -> term array
    case 'import term':
      // Term data have already been saved because mymodule implements the hook_taxonomy and taxonomy_save_term()
      // has been called by taxonomy_export_module before invocate this hook. So there is nothing to do.

      // But I can do anything I want here with the $edit array if I really need!
      break;
  }
}

I need this patch to import/export term fields definitions and data for term_fields module within your module. I will not commit any new release of term_fields module before you agree with my patch, so there is no implementation of this hook in the current code. That's why I wrote above an example of use for the suggested hook.

So I created the patch below which is generic and may work with any module who also needs to use your import/export functionalities.

CommentFileSizeAuthor
taxonomy_export.patch1.56 KBB-Prod
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

James Andres’s picture

I am reluctant to add custom hooks to taxonomy_export because of the API fragmentation it will cause. My preferred approach would be to integrate with one of the export import frameworks:

If you have any thoughts on which would be a better choice it would be great to hear them!

Thanks,

James

James Andres’s picture

I've done a little more research and I think CTools is the way forward. If you're interested in lending a hand the effort is starting here: http://drupal.org/node/625364. Help welcome! :-)

B-Prod’s picture

I just suggested a patch for integration with Features API (625364: Integration with Features API (#1)).

It does not solve the problem I am talking about. Actually there need to be a way to interfere with term and vocabulary objects. It doesn't concern CTools, Features API or anything else, but only taxonomy_export module.

So the patch I suggested above is still required to allow other modules to add information in term ans vocabulary elements.

If you have an other working solution, I am interested in.

James Andres’s picture

Status: Needs review » Fixed

Check out DRUPAL-6--2 dev release for features integration and hook_default_taxonomy_export() :-)

B-Prod’s picture

Thanks!
I will try this release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.